0

In my case I have a starting coordinate x,y,z, an orientation in Quaternion and I know the moved distance.

Basically I would like to know the x',y',z' after applying the transformation and the forward movement. So I am trying to move a point in 3D using quaternion. I guess it should be just a simple calculation but for some reason I cannot find the solution that easily.

In previously I converted the Quaternion to Euler angles and used them to calculate the x',y',z'. Unfortunately because of the Gimbal lock this solution is not suitable for me anymore.

I have found a few example for example this one in python and here's an other in C#, but I still did not get the formula of them as they are discussing the rotation instead of the movement it self, the C# example just changes the middle point of the cube and then it redraws it with the rotation.

Community
  • 1
  • 1
Daniel
  • 383
  • 1
  • 5
  • 20

1 Answers1

2

Why reinvent the wheel ? This kind of operation is best handled via matrixes - and C# has even support for it.

// PresentationCore.dll 
using System.Windows.Media.Media3D;

Matrix3D matrix = Matrix3D.Identity;
matrix.Translate(new Vector3D(x, y, z));
matrix.Rotate(quaterion);
var newPoint = matrix.Transform(point);
Ondrej Svejdar
  • 21,349
  • 5
  • 54
  • 89
  • Let me know if I am wrong but I think here you assume that I know the movement vector, which I do not. My question is basically the movement vector as I know the direction of the movement from quternion and the distance. – Daniel Jun 26 '14 at 12:20
  • 1
    Matrix operations are cumulative - so you first "rotate" the matrix and then you "walk" towards one direction - so you know the vector, it is (Distance, 0, 0). – Ondrej Svejdar Jun 26 '14 at 12:37
  • Thank you, that helped a lot:P I was just playing with my quaternion data as it is not in the same format/order than the Media3D one. – Daniel Jun 26 '14 at 13:06