I have got a quite complex problem. I have a particle simulation program, and i want to add solid objects to it, but still particle-based. for this, i want to deteermine the rotation the given transformation applies to my object. I have been trying to figure this out myself(couldnt find anything too much related to this)

heres what information i have:

  • Old point coordinates
  • New point coordinates
  • Speed on X and Y axis
  • Rotation center

I only need to calculate one points rotation angle(ill solve the rest) heres how far i got:

x' = x * cos( theta ) + y * -sin( theta );
y' = x * sin( theta ) + y * cos ( theta );

I need the value of theta. if possible I need to calculate this 1 million times / frame. If thats too much, then with some tweaking(accuracy lost) 1 000 - 50 000 times. Any other solution of the problem appreticiated. Could this be solved mathematically? If not, then is there some(even if inaccurate) way to solve this problem?

  • $\begingroup$ What's "Speed on X and Y axis"? The linear velocity of the particles along these axes? $\endgroup$ – joriki Apr 23 '12 at 14:06
  • $\begingroup$ Yes.. its how much each particle moves on those axises(its just added to calculate movement) $\endgroup$ – akaltar Apr 23 '12 at 14:11
  • $\begingroup$ How much a particle moves is a distance, not a speed. Do you mean distance or distance per time? $\endgroup$ – joriki Apr 23 '12 at 14:22
  • $\begingroup$ its in pixel/sec - how much my particle moves on X/Y axis given in pixel/sec. anyways ja72 answered my question exactly, thanks $\endgroup$ – akaltar Apr 23 '12 at 17:34
  • $\begingroup$ If that answered your question exactly, then it seems the "speed on the x and y axis" wasn't actually relevant to the question? It seems that what you were actually asking about was to find the rotation angle about the origin, given the coordinates of a point before and after the rotation -- I don't see any speeds there. $\endgroup$ – joriki Apr 23 '12 at 17:42

Starting from :

$$ x' = x \cos\theta - y \sin\theta $$ $$ y' = x \sin \theta + y \cos \theta $$

Use this:

$$ \sin\theta = \frac{ y' x - x' y } {x^2+y^2 } $$ $$ \cos\theta = \frac{ x' x + y' y } {x^2+y^2 } $$


$$ \theta = \tan^{-1}\left( \frac{y' x - x' y}{x' x + y' y } \right) $$

To verify the results

$$ x' = x \cos\theta - y \sin\theta = x \left(\frac{ y' x - x' y } {x^2+y^2 }\right) - y \left( \frac{ x' x + y' y } {x^2+y^2 } \right) = $$ $$ = \frac{x ( x' x+y' y) - y (y' x-x' y) }{x^2+y^2} = \frac{ x' x^2 + x' y^2 }{x^2+y^2} = x' $$

and similarly for $$ y' = x \sin \theta + y \cos \theta = x \left( \frac{ x' x + y' y } {x^2+y^2 } \right) + y \left(\frac{ y' x - x' y } {x^2+y^2 }\right) = \ldots = y'$$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.