XXInteger GeneralRotationMatrixFromEul(XXInteger order, XXDouble *inarr, XXDouble *outarr)
{
	/* inarr is the angles
	   outarr is the MyHMatrix */

	MyHMatrix hM;
	EulerAngles eul;
	
	eul.x = inarr[0];
	eul.y = inarr[1];
	eul.z = inarr[2];
	eul.order = order;

	Eul_ToHMatrix(&eul, &hM);

	/* and fill the result in the matrix */
	FillRotationMatrixArrayFromHMatrix(outarr, &hM);

	/* 0 is success */
	return 0;
}
Exemplo n.º 2
0
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[])
{
    HMatrix R;
    EulerAngles sa, ra;
    const double *p_inangles;
    mxArray *outangles;
    const mwSize dims[]={3,1};
    
    /*get angles*/
    p_inangles=mxGetData(prhs[0]);
    sa.x=(float)p_inangles[0];
    sa.y=(float)p_inangles[1];
    sa.z=(float)p_inangles[2];
    
    /*convert angles from degrees to radians*/
    TORAD(sa.x);
    TORAD(sa.y);
    TORAD(sa.z);
    
    sa.w = EulOrdZYZr;
    Eul_ToHMatrix(sa, R);
    ra = Eul_FromHMatrix(R, EulOrdZXZr);
    
    /*convert angles from radians to degrees*/
    TODEG(ra.x);
    TODEG(ra.y);
    TODEG(ra.z);
    
    if ((plhs[0] = mxCreateNumericArray(2,dims,mxSINGLE_CLASS,mxREAL))==NULL) { mexErrMsgTxt("Memory allocation problem in tom_eulerconvert.\n"); }
    outangles = mxGetData(plhs[0]);
    ((float*)outangles)[0] = ra.x;
    ((float*)outangles)[1] = ra.y;
    ((float*)outangles)[2] = ra.z;
    /*printf("rotating angles = %10.3f %10.3f %10.3f\n", ra.x, ra.y, ra.z);*/
    
    
}