Knowledge Base: Registration export and camera orientations

Default camera position:


(showd is RC’s coordinate system)
Yaw = 0, image is oriented to Y (upper side of image is oriented that way)
Pitch = 0, image is looking down
Roll = 0, image is parallel with X axis

Rotation matrix computation:
inline void FromYPR( __in_ecount( 3 ) double *pYpr, __out_ecount( 9 ) double *pR, __in UINT eulerSignature = 5 )
{
// camera-plane offset
// plane cs: X-north, Y-right, Z-down
// camera is mounted looking down: X-right, Y-plane tail, Z-down
double T[ 9 ];
T[ 0 ] = 0; T[ 1 ] = -1; T[ 2 ] = 0;
T[ 3 ] = 1; T[ 4 ] = 0; T[ 5 ] = 0;
T[ 6 ] = 0; T[ 7 ] = 0; T[ 8 ] = 1;

_ASSERT( Mat33Det( T ) > 0 );

double R[ 9 ];
double intAngles[ 3 ];
intAngles[ 0 ] = pYpr[ 2 ];
intAngles[ 1 ] = pYpr[ 1 ];
intAngles[ 2 ] = pYpr[ 0 ];
MatrixEulerCompose( eulerSignature, intAngles, R );
Mat33Mul( R, T );

// our CS is X-east, Y-north, Z-up
T[ 0 ] = 0;	T[ 1 ] =  1;	T[ 2 ] =  0;
T[ 3 ] = 1;	T[ 4 ] =  0;	T[ 5 ] =  0;
T[ 6 ] = 0;	T[ 7 ] =  0;	T[ 8 ] = -1;
_ASSERT( Mat33Det( T ) > 0 );

Mat33Mul( T, R, pR );

// convert from object rotation to camera rotation (inverse)
Mat33Transpose( pR );
_ASSERT( Mat33Det( pR ) > 0 );

}

In javascript:

EulerRotation: function (y, p, r) {
	var cx = Math.cos(LA.Deg2Rad * r);
	var cy = Math.cos(LA.Deg2Rad * p);
	var cz = Math.cos(LA.Deg2Rad * y);
	var sx = Math.sin(LA.Deg2Rad * r);
	var sy = Math.sin(LA.Deg2Rad * p);
	var sz = Math.sin(LA.Deg2Rad * y);
	return [cx * cz + sx * sy * sz, -cx * sz + cz * sx * sy, -cy * sx,
	-cy * sz, -cy * cz, -sy,
	cx * sy * sz - cz * sx, cx * cz * sy + sx * sz, -cx * cy];
},