Help with an equation!

Game Editor comments and discussion.

Help with an equation!

Postby tlah » Sun Nov 07, 2010 11:27 pm

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
User avatar
tlah
 
Posts: 66
Joined: Sun Apr 06, 2008 12:10 pm
Location: In your head, readin' ur mind
Score: 2 Give a positive score

Re: Help with an equation!

Postby skydereign » Sun Nov 07, 2010 11:35 pm

You can only use ^ for integer values. Use this instead.
Code: Select all
ball.yvelocity=(pow((cos(m)),2) * (sin(90-m)) * vball)
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Help with an equation!

Postby tlah » Tue Nov 09, 2010 12:27 am

Thanks! Should have read the documentation given with the download... Works great!
User avatar
tlah
 
Posts: 66
Joined: Sun Apr 06, 2008 12:10 pm
Location: In your head, readin' ur mind
Score: 2 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest

cron