RadMath.dll, a dll with 17 maths functions for those who need it.
See the z_RadMath_Test.3dr for examples of use.
The zip file contains RadMath.dll to be place in the script directory, the RadMath.3dr project to be used as a script base, and z_RadMath_Test.3dr a test as well as an example project.
The image shows a screen shot of z_RadMath_Test.3dr in operation, and give an overview of the functions available.
z_RadMath_Test.3dr
There are certain functions already available in Rad, such as iFloatCos, iFloatSqrt etc.. But I have included all standard math functions to provide a complete suite.
See the z_RadMath_Test.3dr for examples of use.
The zip file contains RadMath.dll to be place in the script directory, the RadMath.3dr project to be used as a script base, and z_RadMath_Test.3dr a test as well as an example project.
The image shows a screen shot of z_RadMath_Test.3dr in operation, and give an overview of the functions available.
z_RadMath_Test.3dr
Code: [Select]
///****************************************************************************
/// 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_0;
float [] results (17);
//-----------------------------------------------------------------------------
//Print results
//-----------------------------------------------------------------------------
void printResults()
{
iPrint(PS = "sin(15) = "+results[0],-10,11,PRINT);
iPrint(PS = "cos(10) = "+results[1],-10,10,PRINT);
iPrint(PS = "tan(40) = "+results[2],-10,9,PRINT);
iPrint(PS = "radians2degrees(1) = "+results[3],-10,8,PRINT);
iPrint(PS = "degrees2radians(60) = "+results[4],-10,7,PRINT);
iPrint(PS = "acos(0.123) = "+results[5],-10,6,PRINT);
iPrint(PS = "atan(1) = "+results[6],-10,5,PRINT);
iPrint(PS = "asin(0.123) = "+results[7],-10,4,PRINT);
iPrint(PS = "sinh(1) = "+results[8],-10,3,PRINT);
iPrint(PS = "cosh(1) = "+results[9],-10,2,PRINT);
iPrint(PS = "tanh(1) = "+results[10],-10,1,PRINT);
iPrint(PS = "atan2(1,2) = "+results[11],-10,0,PRINT);
iPrint(PS = "exp(1) = "+results[12],-10,-1,PRINT);
iPrint(PS = "log(20) = "+results[13],-10,-2,PRINT);
iPrint(PS = "log10(5) = "+results[14],-10,-3,PRINT);
iPrint(PS = "sqrt(81) = "+results[15],-10,-4,PRINT);
iPrint(PS = "pow(9,2) = "+results[16],-10,-5,PRINT);
}
//-----------------------------------------------------------------------------
//MathTest
//-----------------------------------------------------------------------------
void MathTest()
{
results[0] = R_sin(15);
results[1] = R_cos(10);
results[2] = R_tan(45);
results[3] = R_radians2degrees(1);
results[4] = R_degrees2radians(60);
results[5] = R_acos(0.123);
results[6] = R_atan(1);
results[7] = R_asin(0.123);
results[8] = R_sinh(1);
results[9] = R_cosh(1);
results[10]= R_tanh(1);
results[11]= R_atan2(1,2);
results[12]= R_exp(1);
results[13]= R_log(20);
results[14]= R_log10(5);
results[15]= R_sqrt(81);
results[16]= R_pow(9,2);
}
//-----------------------------------------------------------------------------
//Main
//-----------------------------------------------------------------------------
void Main()
{
if(iInitializing())
{
MathInitialize();
MathTest();
}
else if (iDeinitializing())
{
MathDeInitialize();
}
printResults();
}
There are certain functions already available in Rad, such as iFloatCos, iFloatSqrt etc.. But I have included all standard math functions to provide a complete suite.