line with ellipse/circle collision

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

line with ellipse/circle collision

Post by PGUp »

formula ? or example function, dont want to use physics.
-
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: line with ellipse/circle collision

Post 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?
Last edited by pgimeno on Wed Feb 28, 2018 2:27 pm, edited 1 time in total.
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: line with ellipse/circle collision

Post 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
-
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: line with ellipse/circle collision

Post 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.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: line with ellipse/circle collision

Post 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?
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: line with ellipse/circle collision

Post 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
-
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: line with ellipse/circle collision

Post 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.
-
User avatar
ivan
Party member
Posts: 1911
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: line with ellipse/circle collision

Post by ivan »

I looked it up: with ellipses, you need to skew the line segment which would reduce the problem to circle vs line.
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: line with ellipse/circle collision

Post 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)
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: line with ellipse/circle collision

Post by PGUp »

nvm decided to make my player round instead of weird ellipse shape
-
Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests