Advertisement

Not Math again!

Started by July 25, 2000 06:58 PM
1 comment, last by GeniX 24 years, 5 months ago
Hey all, Heres the scenario : Im coding in C++, and using DirectX. Now the Rotation for my sprite is a float which stores the angle in radians. What I want is to allow the player to press forward and it will add on a value to an xVelocity and yVelocity. So what Im trying to do is multiply the rotation by 57.29 to convert to the usual 360 degrees. Then using SIN, I want to calculate the height, and then using COS I want to calculate the width. The height and width when scaled will give me an addon for my xVelocity and yVelocity. But the values are all screwy. Any help greatly appreciated! regards, GeniX
regards,GeniXwww.cryo-genix.net
I am not sure I understand what u are saying....but one thing i noticed...is that u converted to degrees and then used sin and cos....i thought that sin and cos(in programming) used radians not degrees. Try that and see if it helps. In my program...when the user presses left i add some small amount to my xangle(in degrees) then when the user presses up i move forward based on the sin and cos values, but i convert my degrees to radians before doing this. ie:

if left
yrot += 1
if up
zpos += cos(yrot*piover180)
xpos += sin(yrot*piover180)

Rotate(-yrot, 0, 1, 0)
Translate(-xpos, -ypos, -zpos)

I don''t rmemeber the exact things, but htat is an idea of what i do....it may be wrong cause i forgot but its close.(your using the unit circle basically)!


-blide
blide@mail.com
-blideblide@mail.com
Advertisement
thanks

But shortly after I posted, I figured it out.

You were right. my Formulae were correct, but COS and SIN take radians, not degrees!



regards,

GeniX
regards,GeniXwww.cryo-genix.net

This topic is closed to new replies.

Advertisement