Hello
This are some basic math operations and values which arent in game, I can make more if you find them useful,
Thanks to:
@iAegle for detecting an error.
@SuperNovaAO for a suggestion.
This are some basic math operations and values which arent in game, I can make more if you find them useful,
Code:
e()
{
return ( 2.71828 );
}
pi()
{
return ( 3.14159 );
}
radToDegrees( rad )
{
return ( ( 180 * rad ) / 3.14159 );
}
degreesToRad( degrees )
{
return ( ( degrees * 3.14159 ) / 180 );
}
power( number, exp )
{
numberused = number;
for ( i = 1; i < exp; i++ )
numberused *= number;
return numberused;
}
cotan( angle )
{
return ( cos( angle ) / sin( angle ) );
}
sec( angle )
{
return ( 1 / cos( angle ) );
}
cosec( angle )
{
return ( 1 / sin( angle ) );
}
versin( angle )
{
return ( 1 - cos( angle ) );
}
ValueIsBeetween(value,max,min) //new
{
if(value > min && value < max)
return true;
return false;
}
bisection( angle1, angle2 )
{
return ( ( angle1 + angle2 ) / 2 );
}
pointsAreInLine( point1, point2, point3 )
{
if( ( ( point2[0] - point1[0] ) / ( point3[0] - point1[0] ) ) == ( ( point2[1] - point1[1] ) / ( point3[1] - point1[1] ) ) && ( ( point2[0] - point1[0] ) / ( point3[0] - point1[0] ) ) == ( ( point2[2] - point1[2] ) / ( point3[2] - point1[2] ) ) )
return true;
return false;
}
areParallel( vector1, vector2 )
{
if( ( vector1[0] / vector2[0] ) == ( vector1[1] / vector2[1] ) && ( vector1[0] / vector2[0] ) == ( vector1[2] / vector2[2] ) )
return true;
return false;
}
vectorScale( vector, scale ) //new
{
vec = ( vector[0] * scale, vector[1] * scale, vector[2] * scale );
return vec;
}
vectorDivision( vector, number ) //new
{
vec = ( vector[0] / number, vector[1] / number, vector[2] / number );
return vec;
}
vectorModule( vector )
{
return ( sqrt( ( vector[0] * vector[0] ) + ( vector[1] * vector[1] ) + ( vector[2] * vector[2] ) ) );
}
vectorsAngle( vector1, vector2 ) //new
{
return acos( vectorDot( vector1, vector2 ) / ( vectorModule( vector1 ) * vectorModule( vector2 ) ) );
}
vectorTo2D( vector ) //new
{
return ( vector[0], vector[1], 0 );
}
Thanks to:
@iAegle for detecting an error.
@SuperNovaAO for a suggestion.