h.l.m
h.l.m

Reputation: 13475

How to find the points of intersection between a line and ellipse in R

I would like to find the points of intersection between an ellipse and a line

If using the example (ignoring a few un-needed arguments) from the dataEllipse function from the car package i.e.

x <- dataEllipse(Prestige$income, Prestige$education, levels=0.95, lty=2)

and say you have the horizontal line

abline(14,0)

how do you find the two points of intersection between the line and the ellipse

I know you can get the data that makes the ellipse from just looking at x, however I would like to get the exact points of intersection.

Upvotes: 2

Views: 2087

Answers (2)

Carl Witthoft
Carl Witthoft

Reputation: 21502

I bet there's a curve-fitting method that can get the foci and axis lengths of your ellipse from the set of x-y coords, but it looks tough: http://www.site.uottawa.ca/~mstoj075/Publications_files/EllipseFit.pdf . You might get a "good enough" answer by using splinefun on your set of x-y coordinate data and following the answers in The intersection point between a spline and a line

Upvotes: 0

kostas
kostas

Reputation: 2019

The equation of an ellipse is given by:

x^2/a+y^2/b=1, and the equation of a line by cx+d=y (where a,b,c,d coefficients).

You can substitute y in the ellipse equation. Then the goal is to find the solution of f(x)=0. You can use some method like bisection to solve such a problem.

Check this out:

http://www.math.wichita.edu/~cma/stat774/ch2.pdf

Upvotes: 1

Related Questions