Dark Bit Factory & Gravity

PROGRAMMING => General coding questions => Topic started by: .:] Druid [:. on July 27, 2007

Title: math formula..i suck at math..please help :(
Post 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
Title: Re: math formula..i suck at math..please help :(
Post by: Shockwave on July 27, 2007
Around one axis is easy;

Code: [Select]
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.
Title: Re: math formula..i suck at math..please help :(
Post by: .:] Druid [:. on July 27, 2007
wow..that's fast!  i'm gonna try tonight and give you the feedback!  you're my hero..as usual :)
Title: Re: math formula..i suck at math..please help :(
Post by: Shockwave on July 27, 2007
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.
Title: Re: math formula..i suck at math..please help :(
Post by: .:] Druid [:. on July 27, 2007
thanks again!  my bad, i thought i looked over and over on this forum and did not find it...too stoned maybe :s