Jump to content
  • Advertisement
Sign in to follow this  
AshleysBrain

Rotate point elliptically

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

If you intended to correct an error in the post then please contact us.

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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!