Page 1 of 1

angle of polygon

Posted: Fri May 14, 2004 2:42 am
by Guest
How would it be possible to find the angle at which an image is facing, so that you could calculate the x and y directions it would go using sine and cosine? It would have to be a counter based on 360, but when I try

while key pressed is A and W,

carvelocity += 0.05

carangle +=1.0;
car->setRotation(car->getRotation() + core::vector3df(0,0,carangle));

cary = sin(carangle);
carx = cos(carangle);
v.Y += (cary* carvelocity);
v.X += (carx * carvelocity);



it spins way too fast.

any ideas?

Thanks

Posted: Fri May 14, 2004 3:22 am
by Domarius
I think this thread should be in the General forum, because I think it's a general game programming question, rather than Irrlicht specific.

http://echellon.hybd.net/issues/5/artic ... sincos.htm

This is the best article on making "car" or "asteroids spaceship" movement I've ever read. It should help you tweaking your car to perform properly, with velocity, angle, etc.

Posted: Mon May 17, 2004 5:48 pm
by Guest
is there a function for finding the angle of a poly?

Posted: Tue May 18, 2004 9:42 am
by arras
C++ works with radians not grades.
I got problem when I was coding car movement becouse I was using grades in sin/cos functions:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2233