What's the parametric equation for the general form of an ellipse rotated by any amount? What's the parametric equation for the general form of an ellipse rotated by any amount?
Preferably, as a computer scientist, how can this equation be derived from the three variables: coordinate of the center/two foci and eccentricity of an ellipse?
I need to generate completely random eclipses within certain bounds. The variables I described above are most convenient. This is for a personal project of mine and I can't find anybody who can help me.
 A: Let's start with the parametric equation for a circle centered at the origin with radius 1:

x(t) = cos 2πt
y(t) = sin 2πt

To turn this into an ellipse, we multiply it by a scaling matrix of the form
| a  0 |
| 0  b |

which gives
| a  0 |   | x(t) |   | a x(t) |
| 0  b | * | y(t) | = | b y(t) |

To rotate this by θ degrees, multiply it by the rotation matrix
| cos θ   -sin θ |   | a x(t) |    |a x(t) cos θ - b y(t) sin θ|
| sin θ    cos θ | * | b y(t) | =  |a x(t) sin θ + b y(t) cos θ|

So the new parametric equation would be

x'(t) = a x(t) cos θ - b y(t) sin θ = a cos 2πt cos θ - b sin 2πt sin θ
y'(t) = a x(t) sin θ + b y(t) sin θ = a cos 2πt sin θ + b sin 2πt cos θ

You can then translate this to have center (x0, y0) by adding these components to the parametric components.
Hope this helps!
A: If you have the coordinates (Cx,Cy) of the centre, the coordinates (Fx,Fy) of one of the foci, and the eccentricity e then the parametric equation of the ellipse are
 P(t) = C + cos(t)*A + sin(t)*B

where t is an angle going from 0 to 2*pi, A is the semi-major axis (vector) and B the semi-minor axis; A and B can be calculated like this:
c = hypot( Fx-Cx, Fy-Cy) /* distance from centre to focus */
a = c/e                  /* length of semi-major axis */
b = a*sqrt(1-e*e)        /* length of semi-minor axis */
(Ax,Ay) = (a/c)*(Fx-Cx,Fy-Cy)
(Bx,By) = (b/c)*(Fy-Cy, -(Fx-Cx))

Note that these equations will fail if e=0; but in that case the focus and the centre will be the same and you haven't specified the ellipse (circle) fully as the radius is unknown.
