line with ellipse/circle collision
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: line with ellipse/circle collision
Circle and ellipse are very different problems. Which data do you have? As in, how are the line, the circle and the ellipse specified?
Last edited by pgimeno on Wed Feb 28, 2018 2:27 pm, edited 1 time in total.
Re: line with ellipse/circle collision
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.
https://2dengine.com/?p=intersections#Segment_vs_circle
With ellipses it would be more difficult.
Re: line with ellipse/circle collision
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
thxivan wrote: ↑Wed Feb 28, 2018 2:27 pmSegment 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
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
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
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)
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
nvm decided to make my player round instead of weird ellipse shape

Who is online
Users browsing this forum: Google [Bot] and 16 guests