Problem with rotation

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Foxer
Posts: 2
Joined: Wed Oct 24, 2007 3:51 pm

Problem with rotation

Post by Foxer »

I have built a small program using Irrlicht and Newton. The program is supposed to simulate a car with some basic distance sensors. I use NewtonWorldRayCast in order to detect distance.

I calculate the endpoint of the ray cast by taking the cars position and then adding a vector, taking the cars rotation into account.

example code

Code: Select all

vector3df ray_rotation;
ray_rotation = car_rotation - vector3df(0,45,0);
line3df ray1;			
ray.start = car_position;

matrix4 matt;
			
matt.setRotationDegrees(ray_rotation);					
			
vector3df dist(-100,0.0f,0.0f);
matt.rotateVect(dist);
ray.end.set(dist + start);
This code seems to work just fine until the car comes to a certain angle when suddenly the ray shifts from left to right.
Why does this happen?


Edit

The green line on the right is where the ray is supposed to end up. But instead it points in the opposite direction.
Image
Post Reply