Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Rotation Matrix
Index -> General Discussion
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Raknarg




PostPosted: Thu Apr 12, 2012 10:24 am   Post subject: Rotation Matrix

in this formula:
x = x cos (t) - y sin (t)
y = x sin (t) + y cos (t)

How do you change where the origin is? I want to use this for rotation, but so far I can only get my object to rotate around the point 0, 0.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Thu Apr 12, 2012 10:27 am   Post subject: RE:Rotation Matrix

Actually let me reword that: How do I change the point of rotation?
DemonWasp




PostPosted: Thu Apr 12, 2012 11:10 am   Post subject: RE:Rotation Matrix

What you're using there is actually a specialization of a "transform matrix" ( http://en.wikipedia.org/wiki/Transformation_matrix ) -- one which handles only 2D rotation. Matrix transformations are really excellent because they let you apply multiple distinct transformations in order.

If you don't want to work with matricies, you could do the following:
1. Translate (x,y) such that (0,0) is the point you want to rotate around (rx,ry): (x,y) -= (rx,ry)
2. Rotate (as above)
3. Translate back: (x,y) += (rx,ry)

In most cases, the "rotation point" is just set to be (0,0) when modeling (creating the square, etc), so you can skip steps 1 and 3 and just use step 2.
Raknarg




PostPosted: Thu Apr 12, 2012 10:09 pm   Post subject: RE:Rotation Matrix

Thanks, I got it
Display posts from previous:   
   Index -> General Discussion
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: