Jump to content

  • Log In with Google      Sign In   
  • Create Account

Vertex rotation fails


Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
2 replies to this topic

#1 noatom   Members   -  Reputation: 917

Like
0Likes
Like

Posted 03 March 2014 - 01:35 PM

Keep in mind that I'm really using these coords for a sprite,so I don't care about the Z if that matters at all...

 

 

So i have the following vector:

v(589,277)

 

And I want to rotate it 90 degrees counter clockwise.

 

I build a rotation matrix like this:

D3DXMatrixRotationZ(&rotation, D3DXToRadian(-90));

 

I then just transform the vector with:

D3DXVec2TransformCoord(&res, &D3DXVECTOR2(x,y), &rotation); //x = 589,y = 277

 

The resulting x is the correct one: 276, but the y is very far from the correct result: -589 (it should be something in the range 0-10)

 

What am I doing wrong?

 

 

 

EDIT: I also tried using a 3d vector with the z = 1..the same


Edited by noatom, 03 March 2014 - 01:40 PM.


#2 fastcall22   Crossbones+   -  Reputation: 9060

Like
0Likes
Like

Posted 03 March 2014 - 01:57 PM

D3DXToRadian(90)

Alternatively:
-y, x 90 degrees clockwise
y, -x 90 degrees counter-clockwise

gzip: H4sIAAAAAAAEAG1QTUvEMBC991e8nvaiFfYoS7yo sLCo6MnjtJ1ugmkiyWRL/72z3T1YEQIJ8z4zA2Xp yPvt1qBpGrRFIJZkk9FyRyUzHCbKIHgn4hnZOrm1 TD0mG0HCCs+QGDGWziKXI6Wm2n++GYwUVH2mrGEE PnGCVQ8K8+JYfXA6URDEQfMZh5h6g5eoAlWJdeEI bbH2qYZf7XMUfw8f/Q0oMeZYNL9/WHF0uFEshvMr XYujd9SycFb+F18QcSOvlJauZ8ejqevdnV7/d550 e0t6prmunh73Bu+vz4c/XUeOQXfJgvKNkhf95U8/ Dtgmy5IBAAA=


#3 Buckeye   GDNet+   -  Reputation: 10739

Like
0Likes
Like

Posted 03 March 2014 - 02:53 PM

You're getting the results you're asking for in the calc. A position of 589 on the X-axis rotated by 90 degrees is at -589 on the Y-axis. Can you describe what you're trying to do, rather than how you're trying to do it?

 

Do you want to rotate the sprite by 90 degrees (in its current position), or rotate its position by 90 degrees?

 

If you're trying to rotate the sprite (assuming you're using ID3DXSprite), take a look at ID3DXSprite::SetTransform.


Edited by Buckeye, 03 March 2014 - 03:10 PM.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.





Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.




PARTNERS