Sign in to follow this  
AshleysBrain

Rotate point elliptically

Recommended Posts

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? :)

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sorry folks, I guess I didn't specify the problem properly... the aspect ratio h/w doesn't have to be the same as y/x - it's an extra piece of information that is provided. Sorry :$

I actually managed to solve it very simply using something based alvaro's suggestion: scale the Y axis to make the ellipse in to a circle, rotate circularly, then unscale the Y axis again. It seems to work fine. Here's what I'm doing:

ellipse_ratio = h / w;
p.y *= ellipse_ratio;
rotate p by n degrees
p.y /= ellipse_ratio;

Seems to work - but wouldn't have gotten there without this thread, so thanks... and sorry for the badly phrased question :P Hopefully this will help someone else out if they have the same problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by AshleysBrain
Sorry folks, I guess I didn't specify the problem properly... the aspect ratio h/w doesn't have to be the same as y/x - it's an extra piece of information that is provided. Sorry :$

I can see how people would have been confused by the text in the first post's image which says "ratio of ellipse height / ellipse width (h / w) = y / x", which is precisely the opposite of what you just said.

The only reason why I could help you is because I hadn't read your initial post carefully enough. :)

Share this post


Link to post
Share on other sites
Here is the formula, if I have calculated it right:


You will have to add in plus and minus signs according to which quadrant the angle is in.

Share this post


Link to post
Share on other sites
Sorry, small error. The proper starging forumla is a 1 = x^2/a^2 + y^2/b^2 (a and b are squared). The correction is easy, just substitute in a^2 wherever there is an a and b^2 wherever there is a b in each formula.

Share this post


Link to post
Share on other sites
MazeMaster, surely tan(theta) = y/x. In other words, you should have an arctangent where you have a tangent in your second line.

Also, I find the constraint h/w = y/x odd. Mostly from the fact that this cannot hold up for all points on a ellipse. That is, you'll be rotating around different ellipses if you rotate a point twice.

Share this post


Link to post
Share on other sites
Quote:
Original post by Maze Master
Ahh yes thanks. Here it is with the corrections:


How do you determine if you should use the positive or the negative roots?

I am not even sure what problem you are solving here... Are you trying to determine what the point on the ellipse is that is on a particular ray from the origin? That's not what this thread was about...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this