AshleysBrain 162 Report post Posted June 7, 2009 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? :) 0 Share this post Link to post Share on other sites
gpu_fem 208 Report post Posted June 7, 2009 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) 0 Share this post Link to post Share on other sites
alvaro 21272 Report post Posted June 7, 2009 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? 0 Share this post Link to post Share on other sites
AshleysBrain 162 Report post Posted June 7, 2009 Thanks, but how do I calculate the w and h of the ellipse only knowing point P? 0 Share this post Link to post Share on other sites
gpu_fem 208 Report post Posted June 7, 2009 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. 0 Share this post Link to post Share on other sites
h4tt3n 1974 Report post Posted June 7, 2009 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 0 Share this post Link to post Share on other sites
Stani R 1070 Report post Posted June 7, 2009 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²) / yh = y * sqrt(x² + y²) / xUnless 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. 0 Share this post Link to post Share on other sites
h4tt3n 1974 Report post Posted June 7, 2009 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. 0 Share this post Link to post Share on other sites
Cakey 144 Report post Posted June 7, 2009 Your gonna need to have at least two points to solve this. 0 Share this post Link to post Share on other sites
Stani R 1070 Report post Posted June 7, 2009 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. 0 Share this post Link to post Share on other sites
AshleysBrain 162 Report post Posted June 7, 2009 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 degreesp.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. 0 Share this post Link to post Share on other sites
alvaro 21272 Report post Posted June 8, 2009 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.The only reason why I could help you is because I hadn't read your initial post carefully enough. :) 0 Share this post Link to post Share on other sites
Maze Master 510 Report post Posted June 8, 2009 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. 0 Share this post Link to post Share on other sites
Maze Master 510 Report post Posted June 9, 2009 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. 0 Share this post Link to post Share on other sites
Ezbez 1164 Report post Posted June 9, 2009 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. 0 Share this post Link to post Share on other sites
Maze Master 510 Report post Posted June 9, 2009 Ahh yes thanks. Here it is with the corrections: 0 Share this post Link to post Share on other sites
alvaro 21272 Report post Posted June 9, 2009 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... 0 Share this post Link to post Share on other sites