Rotate point elliptically

Started by
15 comments, last by alvaro 14 years, 10 months ago
Hey everyone, I've googled a bit etc and haven't found a solution to this - how do you rotate a point around the origin elliptically? I'm cool with ordinary circular rotations, but I'm stumped on ellipses. This image explains the problem: Given point P(x, y), how do you rotate it elliptically around the origin? All that is known about the ellipse is that point P lies on it, and that the ratio of the ellipse height / ellipse width is the same ratio as the point P's y / x. Does a solution exist (I hope it does!) and if so, anyone know how to solve this? :)
Construct (Free open-source game creator)
Advertisement
An ellipse is parameterized in theta coordinates as

x = w*cos(theta)
y = h*sin(theta)

where theta is measured ccw from the +x axis (standard polar notation). Then for P, you can find its theta by t = atan2( y/h , x/w ). Then new_theta = t + delta_theta. You can then calculate the new x,y.

It looks like you are using a cw theta notation - My answer is for theta ccw, so you will have to make the appropriate adjustments (or change the orientation of theta)
If you transform your image by mapping every point (x,y) to (x/w,y/h), your ellipse becomes the unit circle. You can then apply a regular rotation and then map back using (x,y) |-> (x*w,y*h). All three operations are linear, so their composition is linear as well. It should be easy to write down the exact formula.

Does that answer your question?
Thanks, but how do I calculate the w and h of the ellipse only knowing point P?
Construct (Free open-source game creator)
w = x / cos(theta)

h = y / sin(theta)

This works as long as the point is not on the x or y axis. In this case knowing the x,y coordinates of the point does not give you enough information to find w and h.
Quote:Original post by AshleysBrain
Thanks, but how do I calculate the w and h of the ellipse only knowing point P?


Well, that depends on exactly what P is, so please tell us. As an example, I just solved this exact same problem for gravitationally interacting bodies. Given the state vectors of point p I could calculate its elliptic trajectory around the central body. But if your P is just a point, then there will be infinitely many solutions to w and h.

cheers,
Mike
Uhm, maybe I am missing something obvious, but why is this not enough info? You can find theta from x an y, it being the arcsine of x over the square root of x squared plus y squared (theta = arcsin(x/sqrt(x² + y²)), can't you? Pythagorean theorem plus some basic properties of right triangle. And with x, y, and theta, you have enough info to solve the rest.

Or simplified:

w = x * sqrt(x² + y²) / y
h = y * sqrt(x² + y²) / x

Unless I made some big thinking mistake somewhere. I'm not sure if theta needs to change to account for which quadrant the point is in, but if it does, you can just compute the arcsine or arccosine, add 90/180/270 degrees, and compute sine or cosine again.
Just picture it. If all you know is a point P on an ellipse and its centre C, you can have infinitely many h's and w's which are all satisfying p and c.
Your gonna need to have at least two points to solve this.
Hmm that's true. Although they won't all satisfy the constraints y/x = h/w. But I just looked up paramteric ellipse on wikipedia, and I realized that the theta gpu_fem's formula is not actually theta the angle, but t the eccentric anomaly. My mistake, been a while since I did trig properly.

This topic is closed to new replies.

Advertisement