Need some quick maths (rotation) help
Monkey Forums/Monkey Beginners/Need some quick maths (rotation) help
| ||
PushMatrix() DrawText("Test2", 100, 400) Rotate(ang) DrawText("Test", 400, 600) ang += 0.1 PopMatrix() So in the above snippet, the word "Test" is first printed at 400,600 (because ang = 0.0), but as the rotation increases, so does the x & y values. If I want to have the rotation go through 360 degrees, how do I keep it so that my message text is written to the 400,600 position on my screen? I'm guessing I need to transform the 400,600 by the angle (Sin and/or Cos functions?) I know this will be a simple answer, I just can't get my brain around it at the moment. |
| ||
Translate first, so that it rotates around 400,600, then DrawText at 0,0.PushMatrix() DrawText("Test2", 100, 400) Translate(400, 600) Rotate(ang) DrawText("Test", 0, 0) ang += 0.1 PopMatrix() |
| ||
@Samah - Thanks. I knew it was something simple and had half a thought about Translate. Cheers for the quick help, saved me some head bashing :) |
| ||
@Samah - Thanks. I knew it was something simple and had half a thought about Translate. Cheers for the quick help, saved me some head bashing :) No problem. :) That will rotate about the top left corner of the text, though. If you want to centre the text on 400, 600 you'll need to set an alignment. I think this is it: DrawText("Test", 0, 0, 0.5, 0.5) |