## line with ellipse/circle collision

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

### line with ellipse/circle collision

formula ? or example function, dont want to use physics.
-

pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

### 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.

PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

### Re: line with ellipse/circle collision

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

ivan
Party member
Posts: 1564
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### 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.

pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

### 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?

PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

### Re: line with ellipse/circle collision

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

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.
-

ivan
Party member
Posts: 1564
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

### 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.

pgimeno
Party member
Posts: 2211
Joined: Sun Oct 18, 2015 2:58 pm

### 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)

PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

### 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: No registered users and 19 guests