Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solutions for y for a rotated ellipse

Tags:

math

ellipse

I wish to plot an ellipse by scanline finding the values for y for each value of x.

For a plain ellipse the formula is trivial to find: y = Sqrt[b^2 - (b^2 x^2)/a^2]

But when the axes of the ellipse are rotated I've never been able to figure out how to compute y (and possibly the extents of x)

like image 230
hippietrail Avatar asked Dec 07 '22 00:12

hippietrail


1 Answers

In parametric form

x[t]= a Cos[t] Cos[psi] - b Sin[t] Sin[psi]

y[t]= b Cos[psi] Sin[t] + a Cos[t] Sin[psi]

Where psi is the rotation angle, and a and b the semi-axes.

The parameter t goes from 0 to 2 Pi.

Or if you prefer in Cartesian non-parametric form:

(a x^2+b y^2) Cos[psi]^2 + (b x^2 +a y^2) Sin[psi]^2 + (a-b) x y Sin[2 psi]==1

Which yields to the two possible solutions for y[x], equivalent to the two solutions for the square root in the non-rotated case:

y -> (-(Sqrt[2]*Sqrt[a + b - 2*a*b*x^2 + (-a + b)*Cos[2*psi]]) + 
       (-a + b)*x*Sin[2*psi]) / (2*(b*Cos[psi]^2 + a*Sin[psi]^2))

y ->   (Sqrt[2]*Sqrt[a + b - 2*a*b*x^2 + (-a + b)*Cos[2*psi]] + 
       (-a + b)*x*Sin[2*psi])/ (2*(b*Cos[psi]^2 + a*Sin[psi]^2))

Well, you asked for it :)

Those functions give:

enter image description here

And the limits for x are:

LimitX= +/- Sqrt[a + b + (-a + b)*Cos[2*psi]]/(Sqrt[2]*Sqrt[a]*Sqrt[b])
like image 67
Dr. belisarius Avatar answered Feb 28 '23 06:02

Dr. belisarius