# Rotate point elliptically

This topic is 3107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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.

##### Share on other sites
Thanks, but how do I calculate the w and h of the ellipse only knowing point P?

##### 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 on other sites
Quote:
 Original post by AshleysBrainThanks, 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 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 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 on other sites
Your gonna need to have at least two points to solve this.

##### 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.

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 AshleysBrainSorry 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.

##### 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 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 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 on other sites
Ahh yes thanks. Here it is with the corrections:

##### Share on other sites
Quote:
 Original post by Maze MasterAhh 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 on other sites

This topic is 3107 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628639
• Total Posts
2983972

• 10
• 18
• 20
• 13
• 9