0
$\begingroup$

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?

  • 0
    What's "Speed on X and Y axis"? The linear velocity of the particles along these axes?2012-04-23
  • 0
    Yes.. its how much each particle moves on those axises(its just added to calculate movement)2012-04-23
  • 0
    How much a particle moves is a distance, not a speed. Do you mean distance or distance per time?2012-04-23
  • 0
    its in pixel/sec - how much my particle moves on X/Y axis given in pixel/sec. anyways ja72 answered my question exactly, thanks2012-04-23
  • 0
    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.2012-04-23
  • 0
    I didnt know what is needed to calculate it... I put all information I had there2012-04-24
  • 0
    I see -- apologies for being overly critical. Actually the opposite problem is worse; people sometimes omit information they think isn't relevant but then it turns out that it was, and it takes ages to clarify the incomplete question...2012-04-24

1 Answers 1

1

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