PDA

View Full Version : Angular/Position velocity by using quaternion - problems.



Sword7
04-14-2013, 06:30 PM
Hello folks,

I am working on my orbital flight simulator. I recently implemented keyboard controls to fly spacecraft. However, I have some problems with velocity. I tried to press a key to move forward but it moves in off-course direction. With away from zero Z axis, I tried to rotate up, down, left, or right and it rotate (wrong) off-course direction. It only works with zero Z axis with both position and angular movement. Does anyone have or recommend good algorithms for movement control with any Z axis? I searched for that through Internet but did not find information much.



Quaternion<double> orientation(1.0);

void setTravelVelocity(double s)
{
:
travelVelocity = Vector3<double>(0, 0, s) * orientation;
:
}

void update(double dt)
{
:
position += travelVelocity * dt;
orientation += (angularVelocity * orientation) * dt;
orientation.normalize();
:
}


Thanks!
Sword7