0

I am having trouble finding the right yaw, pitch, and roll. I have a 3 boxes place in a random plane.

Image with the boxes

I want to find the yaw, pitch, and roll for each box. The formula that I am using is:

string _outOrientation = string.Empty;
Point3d _worldPointA = new Point3d(0.0, 0.0, 0.0);
Point3d _worldPointB = new Point3d(0.0, 0.0, 1.0);
Vector3d _worldZvector = _worldPointB - _worldPointA;

Plane _scenePlane = new Plane(_worldPointA, _worldZvector);
Plane _orientationPlane = _planeBase;

//here is a 4x4 tranformation matrix
Orientation _orientation = new Orientation(_scenePlane, _orientationPlane);

Transform _transform = _orientation.ToMatrix();
//ROLL 
double Aradian = Math.Atan2(_transform.M21, _transform.M22);
//PITCH 
double Bradian = -Math.Atan2(_transform.M20, Math.Sqrt(_transform.M21 * _transform.M21 + _transform.M22 * _transform.M22));
//YAW 
double Cradian = Math.Atan2(_transform.M10, _transform.M00);

//ROLL to degree
 double Adegree = RadianToDegree(Aradian);                                                                         
//PITCH to degree
 double Bdegree = RadianToDegree(Bradian);
//YAW to degree
double Cdegree = RadianToDegree(Cradian);

_outOrientation = string.Format("{0} {1} {2}", Adegree.ToString(), Bdegree.ToString(), Cdegree.ToString());

My result is this this.

Tengku Fathullah
  • 1,279
  • 1
  • 18
  • 43
  • You've not asked a question. Which part of your code are you having difficulty with? – Steve Jan 06 '17 at 09:45
  • My problems is after. I run the code i got the wrong yaw, pitch, and roll. I want to try to find the right matrix to get this sequence of transformations. but i dont know how to to do it. . The plane(x,y,z) is rotated around reference x giving plane(x',y',z'), then is rotated around its new y' vector giving plane(x'',y'',z'') and finally rotated around its new z'' vector giving plane(x''',y''',z'''). – Starsky Lara Jan 06 '17 at 09:48
  • If I guess right you are implementing a matrix decomposition technique? Do you have a Wikipedia link to the decomposition method you use? Or a name? – Crouching Kitten Jan 06 '17 at 12:26
  • In your place I would do this in two steps: first ask the question in the "Mathematics" community, how to decompose that matrix to "rotation1 x translation x rotation2". (And specifiy the rotations by their axis.) Then after you have the answer, and tried to implement it, could come back here to fix it :) – Crouching Kitten Jan 06 '17 at 12:38
  • (But I can see that not any matrices can be decomposed that way, because the ability for stretching is missing from "rotation1 x translation x rotation2". So you also need a test to decide whether the decomposition is possible.) – Crouching Kitten Jan 06 '17 at 12:45

0 Answers0