Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
    
What's "Speed on X and Y axis"? The linear velocity of the particles along these axes? –  joriki Apr 23 '12 at 14:06
    
Yes.. its how much each particle moves on those axises(its just added to calculate movement) –  akaltar Apr 23 '12 at 14:11
    
How much a particle moves is a distance, not a speed. Do you mean distance or distance per time? –  joriki Apr 23 '12 at 14:22
    
its in pixel/sec - how much my particle moves on X/Y axis given in pixel/sec. anyways ja72 answered my question exactly, thanks –  akaltar Apr 23 '12 at 17:34
    
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. –  joriki Apr 23 '12 at 17:42
show 2 more comments

1 Answer 1

up vote 1 down vote accepted

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 } $$

so

$$ \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'$$

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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