Page 1 of 1

Help with an equation!

PostPosted: Sun Nov 07, 2010 11:27 pm
by tlah
Hello all,
haven't been here in a while... Anyway, science fair time is rolling in again for my school. I am working on a golf physics simulator and have worked out many bugs except for a major problem involving the velocity of the ball (or in Game Editor language, the yvelocity...) The compiler displays an "incompatible type" error.

All of my variables are Real numbers:
m = the angle of the club in degrees
initVel = the initial velocity of the ball
mass = 49.6 (average mass for a golf ball, in grams)
club = mass the club head (in grams)
vball = ball's velocity (defined earlier in the program), using the code:
Code: Select all
vball = ((initVel*1.67))/(1+mass/club)))

Here is the bugged code:
Code: Select all
ball.yvelocity=((cos(m))^2*(sin(90-m))*vball)

for some reason, the compiler does not like when I use powers. Is there any way to fix this? I don't want to simply multiply the cosine of m by itself... There's GOT to be an easier way!

As always, thanks in advance!
-Tlah

Re: Help with an equation!

PostPosted: Sun Nov 07, 2010 11:35 pm
by skydereign
You can only use ^ for integer values. Use this instead.
Code: Select all
ball.yvelocity=(pow((cos(m)),2) * (sin(90-m)) * vball)

Re: Help with an equation!

PostPosted: Tue Nov 09, 2010 12:27 am
by tlah
Thanks! Should have read the documentation given with the download... Works great!