How to calculate the translation vector in local s

Community Forums/General Help/How to calculate the translation vector in local s

RemiD(Posted 2014) [#1]
Hello,


I need some help to calculate the translation vector in local space.

I am trying to code a simulation of the turns moves of a spaceship in space.

The spaceship is turned moved with forces.

Each force can increase or decrease the anglevelocity and the movementvelocity and thus the rotation and the translation of the spaceship in global space.

I already know the oldorientation (picth,yaw,roll), oldposition (x,y,z), the translation vector in global space (vx,vy,vz), the neworientation (picth,yaw,roll), the newposition (x,y,z).

I need a way to calculate the translation vector in local space.

To illustrate what i mean :


The white arrow represents the translation vector in global space.
The red arrow represents the local x axis of the spaceship
The green arrow represents the local y axis of the spaceship
The blue arrow represents the local z axis of the spaceship

I want to calculate the translation vector in local space which corresponds to the translation vector in global space. (=how much the spaceship must move on each local axis to go from the oldposition to the newposition)

I need these values in order to position rotate the camera depending on the spaceship local neworientation newposition and depending on the translation in global space.

Any ideas on how to calculate this vector ?


Thanks,
Regards,


Kryzon(Posted 2014) [#2]
If you're using Blitz3D, you can use TFormVector with...
TFormVector( worldX, worldY, worldZ, 0, spaceship ) - transforming the world vector from world space to the local space of the entity.

If you're not using Blitz3D, you need to multiply that Vec3 world position by the matrix of the spaceship. When you multiply a vector by a matrix, the resulting vector is described in the space of that matrix, with the world position and rotation of the matrix as the new origin.

For more support:
http://www.gamedev.net/forum/20-math-and-physics/


RemiD(Posted 2014) [#3]

TFormVector( worldX, worldY, worldZ, 0, spaceship ) - transforming the world vector from world space to the local space of the entity.


As simple as that ? Thanks man, i will try. :)