Dark Bit Factory & Gravity
PROGRAMMING => General coding questions => Topic started by: .:] Druid [:. on July 27, 2007
-
Hi guys....sorry to bother with a new thread but i really suck at math and i'm tired of searching...this will be pretty simple for most of you:
what is the rotation formula? if i draw a square or a triangle, how can i rotate it??? thanks in advance for your help
-
Around one axis is easy;
theta = angle
xold = x
yold = y
xnew = cos(theta)*xold - sin(theta)*yold
ynew = sin(theta)*xold + cos(theta)*yold
x=xnew
y=ynew
Hope that helps.
-
wow..that's fast! i'm gonna try tonight and give you the feedback! you're my hero..as usual :)
-
No worries :)
I just remembered that Emil asked a similar thing (but for rectangles) and I wrote some example code in freebasic, it is here;
http://dbfinteractive.com/index.php?topic=2134.0 (http://dbfinteractive.com/index.php?topic=2134.0)
So that should get it working for you mate.
-
thanks again! my bad, i thought i looked over and over on this forum and did not find it...too stoned maybe :s