Page 1 of 2

line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:19 pm
by PGUp
formula ? or example function, dont want to use physics.

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:27 pm
by pgimeno
Circle and ellipse are very different problems. Which data do you have? As in, how are the line, the circle and the ellipse specified?

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:27 pm
by PGUp
pgimeno wrote: Wed Feb 28, 2018 2:27 pm Circle and ellipse are very different problems. Which data do you have?
circle for now

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:27 pm
by ivan
Segment vs circle is relatively easy, you just project the center of the circle on the line:
https://2dengine.com/?p=intersections#Segment_vs_circle
With ellipses it would be more difficult.

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:31 pm
by pgimeno
I guess you have the line specified as two points, and the circle as centre and radius. Is this correct? If so, what Ivan posted shows how to detect the collision. If you want to resolve it, you will need more work. How do you specify ellipses?

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:32 pm
by PGUp
ivan wrote: Wed Feb 28, 2018 2:27 pm Segment vs circle is relatively easy, you just project the center of the circle on the line:
https://2dengine.com/?p=intersections#Segment_vs_circle
With ellipses it would be more difficult.
thx

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:35 pm
by PGUp
pgimeno wrote: Wed Feb 28, 2018 2:31 pm I guess you have the line specified as two points, and the circle as centre and radius. Is this correct? If so, what Ivan posted shows how to detect the collision. If you want to resolve it, you will need more work. How do you specify ellipses?
for the ellipse, need to check line segment with the ellipse, not trying to resolve it. it seems hard, im fine if i dont find the answer though.

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 2:58 pm
by ivan
I looked it up: with ellipses, you need to skew the line segment which would reduce the problem to circle vs line.

Re: line with ellipse/circle collision

Posted: Wed Feb 28, 2018 3:02 pm
by pgimeno
I think we have a problem of miscommunication.

A circle can be specified by giving a centre point, and a radius. It can also be specified by giving two diametrically opposite points. It can also be specified by giving three points that lie on it. There are probably more ways.

A line can be specified by giving two points that lie on it. Or by giving a point that lies on it and a vector that points in the same direction. Or by giving the slope and the point where it cuts one axis. Or by giving a point and an angle. Or by many other possible ways.

An ellipse can be specified by giving five points that lie on it. Or by giving the centre, the radii and the angle. Or by giving the two foci and the sum of the distances to the foci. Or by giving the centre, one radius, the aspect ratio and the angle. Or by many other possible ways.

How do you specify your lines, your circles and your ellipses? And more importantly, are they axis aligned? (axis aligned collisions are far simpler)

Re: line with ellipse/circle collision

Posted: Thu Mar 01, 2018 9:59 am
by PGUp
nvm decided to make my player round instead of weird ellipse shape