Compute intersection between Line and Arc

I am implementing a little game in c with sdl2/sdl_gfx for an assignment where you need to avoid the arcs coming at you (in the center) by moving the little cursor under the white circle (it moves around the circle).

My question is simple: what can be an efficient implementation to detect if my cursor intersect an arc?

For each arcs have : the center point (x,y), starting and ending points, radius.
Which are the arguments of:

int arcRGBA(SDL_Renderer *renderer, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

For my cursor (the little triangle under the circle) i have : the coordinates of the triangle.

int filledTrigonRGBA(SDL_Renderer *renderer, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint8 r, Uint8 g, Uint8 b, Uint8 a)

Having this information, i thought about using Lines of my triangle to detect if it intersects with an arc. But i dont know how to implement it with the maths involved in it.

enter image description here

Note: The Arcs are moving and their coordinates are updated each frame. I only need to know the implementation to detect an intersection.
Thankyou :wink:

First try implementing collision of your cursor versus circle - that’s pretty much basic one. If you don’t know how, you can use this source as reference:


Then check whether or not the points of intersection are in the “domain” of the function drawing your arc.

1 Like

I’d keep it simple and calculate the angle from the centre of your circle to the points of the base on your triangle, then when the arcs’ radius are between the distance from the centre of the circle to the point of your triangle, and the distance from the centre to the base, just check if the angle your arc starts and stops at overlaps the angle that the base of your cursor is at.

BTW if your game is based on Super Hexagon I used to hang out with the author of that game at an Indie meetup in Cambridge!