NxOgre::Vec3 what happen?

tomneo2000

24-09-2009 07:12:33

ok i have checked my calculation for many time, but result is strange

1. vv is a type of NxOgre::Vec3 and also a body's global position {x=0.000000, y=37.525463, z=0.000000}(constant)
2. xinc and yinc both are 0 first time into loop increase every time and also they are type of float
3. posrange is a constant value always 20.0 and also type of float


First loop the result of pos is {x=21.000000, y=57.525463, z=0.0000000}

Second loop the result of pos is {x=19.160929 y=56.981441 z=0.00000000 }

third loop the result of pos is {x=20.408083 y=58.438408 z=0.00000000 }

fourth loop the result of pos is {x=20.154251 y=56.537430 z=0.00000000 }

fifth loop the result of pos is {x=19.333061 y=58.270576 z=0.00000000 }

have you seen that is really strange, xinc and yinc are increase 10 every so, it is suppose to be like this

first: cos(0)=1, sin(0)=0
second: cos(10)=0.984, sin(10)=0.173
third: cos(20)=0.939, sin(20)=0.342

calculation:
vv position and posrange are never change

vv.x+cos(xinc)+posrange-------->suppose decrease slowly
vv.y+sin(yinc)+posrange--------->suppose increase slowly

Shoot, the result not correct and strange any body know what the hell is going on?


for(int i=0; i<10; i++)
{
NxOgre::Vec3 pos=NxOgre::Vec3(Real(vv.x+cos(xinc)+posrange), Real(vv.y+sin(yinc)+posrange), 0);
xinc+=10.0;
yinc+=10.0;
}

betajaen

24-09-2009 11:05:39

No, it's you.

All cosine, sine and tangent functions are required to be in radians, not degrees:

cos(20 radians) = 0.408082062
cos(20 degrees) = 0.939692621

Vec3 is fine. Your just working in the wrong units.