So here is the code of the World Angle of the WINDARROW
Compass Heading (y axis)
y: 0 to 360
pitch and bank
z: 0 to 90 (airplane is climbing pointing up North)
-0 to -90 (airplane is going down direction North)
200 to 290 ((positive = climbing) in the other side the number "2" is similar to "S" South)
-200 to -290 (negative is descending South direction)
NOTE: the number "2" of 200 is just a reference for South
pitch and bank
x: 0 to 90 (airplane has pitch if it looks North)
-0 to -90
200 to 290
-200 to -290
//****************************************************************************
/// START OF RADMATH FUNCTION BLOCK
///****************************************************************************
int MathDLLHandle=0;
int POINTER = OBJ_0;
float [] AxisValue (4);
//-----------------------------------------------------------------------------
//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\\RadMath2.dll");
}
//-----------------------------------------------------------------------------
//MathDeInitialize
//-----------------------------------------------------------------------------
void MathDeInitialize()
{
if (MathDLLHandle != 0)
iDLLUnload(MathDLLHandle);
}
//-----------------------------------------------------------------------------
//R_vectorAngle - Returns angle between vectors
//-----------------------------------------------------------------------------
float R_vectorAngle(Vector3 a, Vector3 b)
{
Vector3 na,nb;
float dot, angle;
iVectorLengthSet(na,a,1);
iVectorLengthSet(nb,b,1);
dot = iVectorDot(na,nb);
angle = R_acos(dot);
angle = R_radians2degrees(angle);
return angle;
}
//-----------------------------------------------------------------------------
//R_quat2axis - Returns the axis angles from a quaternion
//-----------------------------------------------------------------------------
void R_quat2axis(Quaternion q)
{
Vector3 v;
float x,y,z,w;
string s;
x=q.x; y=q.y; z=q.z; w=q.w;
iDLLArraySet(0,x);
iDLLArraySet(1,y);
iDLLArraySet(2,z);
iDLLArraySet(3,w);
iDLLCall(MathDLLHandle,"R_quat2axis",0);
float angle = iDLLArrayGet(0);
x = iDLLArrayGet(1); s=x; if(s=="-1.#IND") x=0;
y = iDLLArrayGet(2); s=y; if(s=="-1.#IND") y=0;
z = iDLLArrayGet(3); s=z; if(s=="-1.#IND") z=0;
AxisValue[0]=angle;
AxisValue[1]=x;
AxisValue[2]=y;
AxisValue[3]=z;
}
///****************************************************************************
/// END OF RADMATH FUNCTION BLOCK
///****************************************************************************
//Add your globals here
Vector3 WL , PL ; //AirplaneLocation PastLocation
Vector3 WorldLocationPL; // PastLocation move to 000 worl location
float alpha,degreeX, compass, degreeZ, compass360, degreeZ90, degreeX90;
Vector3 v;
Quaternion q;
float angle;
string PS;
int PRINT = OBJ_88;
void Main()
{
if(iInitializing())
{
MathInitialize();
}
else if (iDeinitializing())
{
MathDeInitialize();
}
PL = WL; /// ad Past Location , as i learn here from jestermon
iObjectLocation ( OBJ_22 , WL ) ; //OBJ_22 is the WindArrow of the Airplane
degreeX = R_radians2degrees(R_atan2(WL.y - PL.y,WL.x - PL.x));//primero la altura y luego la distancia
if (degreeX>90) {degreeX90=380-degreeX;} //this change the degrees from 0 to 90 North direccion and 200 to 290 in South direccion (The "2" indicate direction S )
else if (degreeX<-90) {degreeX90=(-1*380)-degreeX;}
else {degreeX90=degreeX;}//this change the degrees from -0 to -90 North direccion and -200 to -290 in South direccion (The "2" indicate direction S )
compass = R_radians2degrees(R_atan2(WL.x - PL.x,WL.z - PL.z));//primero la distncia EO y luego la distancia NS
if (compass<0) {compass360=360-(compass*-1);}else{compass360=compass;}//this change the degrees in to compass style
degreeZ = R_radians2degrees(R_atan2(WL.y - PL.y,WL.z - PL.z));//primero la altura y luego la distanciaNS
if (degreeZ>90) {degreeZ90=380-degreeZ;}///else{degreeZ90=degreeZ;}//this change the degrees from 0 to 90 North direccion and 200 to 290 in South direccion (The "2" indicate direction S )
else if (degreeZ<-90) {degreeZ90=(-1*380)-degreeZ;}
else {degreeZ90=degreeZ;}//this change the degrees from -0 to -90 North direccion and -200 to -290 in South direccion (The "2" indicate direction S )
// OUT_22 44 and 66 was ValuePrint and now we have iObjectTextSet
iObjectTextSet(PRINT, PS ="WIND ARROW WORLD ANGLE EO x="+degreeX90+" COMPASS y="+compass360+" NS z="+degreeZ90);
}
Can a guru clean it and make it more compact?
I'm Junior!