...and this is using jestermon's math dll.
///****************************************************************
/// START OF RADMATH FUNCTION BLOCK
///****************************************************************
int MathDLLHandle=0;
//-----------------------------------------------------------------
//R_radians2degrees
//-----------------------------------------------------------------
float R_radians2degrees(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_radians2degrees",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_degrees2radians
//-----------------------------------------------------------------
float R_degrees2radians(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_degrees2radians",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_cos
//-----------------------------------------------------------------
float R_cos(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_cos",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_sin
//-----------------------------------------------------------------
float R_sin(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_sin",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_tan
//-----------------------------------------------------------------
float R_tan(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_tan",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_acos
//-----------------------------------------------------------------
float R_acos(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_acos",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_atan
//-----------------------------------------------------------------
float R_atan(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_atan",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_asin
//-----------------------------------------------------------------
float R_asin(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_asin",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_sinh
//-----------------------------------------------------------------
float R_sinh(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_sinh",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_cosh
//-----------------------------------------------------------------
float R_cosh(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_cosh",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_tanh
//-----------------------------------------------------------------
float R_tanh(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_tanh",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_atan2
//-----------------------------------------------------------------
float R_atan2(float value1, float value2)
{
iDLLArraySet(0,value1);
iDLLArraySet(1,value2);
iDLLCall(MathDLLHandle,"R_atan2",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_exp
//-----------------------------------------------------------------
float R_exp(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_exp",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_log
//-----------------------------------------------------------------
float R_log(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_log",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_log10
//-----------------------------------------------------------------
float R_log10(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_log10",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_sqrt
//-----------------------------------------------------------------
float R_sqrt(float value)
{
iDLLArraySet(0,value);
iDLLCall(MathDLLHandle,"R_sqrt",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//R_pow
//-----------------------------------------------------------------
float R_pow(float value1, float value2)
{
iDLLArraySet(0,value1);
iDLLArraySet(1,value2);
iDLLCall(MathDLLHandle,"R_pow",0);
float f = iDLLArrayGet(0);
return f;
}
//-----------------------------------------------------------------
//MathInitialize
//-----------------------------------------------------------------
void MathInitialize()
{
MathDLLHandle = iDLLLoad(".\\3DRad_res\\objects\\Script\\RadMath.dll");
}
//-----------------------------------------------------------------
//MathDeInitialize
//-----------------------------------------------------------------
void MathDeInitialize()
{
if (MathDLLHandle != 0)
iDLLUnload(MathDLLHandle);
}
///****************************************************************
/// END OF RADMATH FUNCTION BLOCK
///****************************************************************
//Add your globals here
string PS;
int PRINT = OBJ_3;
//*****************************************************************
// MAIN
//*****************************************************************
void Main()
{
//*************************************************************
// INIT
//*************************************************************
if(iInitializing())
{
MathInitialize();
}
//*************************************************************
// UPDATE
//*************************************************************
Quaternion Rot;
iObjectOrientation(OBJ_0,Rot); //Get Rotation
Vector3 v1;
QuatToEulerAngles(Rot,v1);
iPrint(PS = v1.y,-10,11,PRINT);
//*************************************************************
// DESTROY
//*************************************************************
if (iDeinitializing())
{
MathDeInitialize();
}
//-------------------------------------------------------------
}
//*****************************************************************
//ODDITYENGINE - MATH - QUATERNION TO EULER ANGLES
//*****************************************************************
void QuatToEulerAngles(Quaternion q1,Vector3 &out EulerAngles)
{
//-------------------------------------------------------------
Vector3 v1;
v1.x = R_atan2
(
(2 * q1.y * q1.w - 2 * q1.x * q1.z),
(1 - 2 * R_pow(q1.y, 2) - 2 * R_pow(q1.z, 2))
);
v1.z = R_asin
(
2 * q1.x * q1.y + 2 * q1.z * q1.w
);
v1.y = R_atan2
(
(2 * q1.x * q1.w - 2 * q1.y * q1.z),
(1 - 2 * R_pow(q1.x, 2) - 2 * R_pow(q1.z, 2) )
);
if (q1.x * q1.y + q1.z * q1.w == 0.5)
{
v1.x = (2 * R_atan2(q1.x,q1.w));
v1.y = 0.0f;
}
else if (q1.x * q1.y + q1.z * q1.w == -0.5)
{
v1.x = (-2 * R_atan2(q1.x,q1.w));
v1.y = 0.0f;
}
EulerAngles.x = R_radians2degrees(v1.y);
EulerAngles.y = R_radians2degrees(v1.x);
EulerAngles.z = R_radians2degrees(v1.z);
return;
//-------------------------------------------------------------
}