ItsMods

Full Version: Simple Math Commands
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hello

This are some basic math operations and values which arent in game, I can make more if you find them useful, Smile

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.
(01-25-2012, 18:03)Yamato Wrote: [ -> ]Hello

This are some basic math operations and values which arent in game, I can make more if you find them useful, Smile
Code:
...

exp( number, exp )
{
    numberused = number;
    for ( i = 1; i < exp; i++ )
        numberused *= number;
    return numberused;
}

...

Code:
exp( number, exp )
{
return number ^ exp;
}

Huh

I guess these could help someone though lol
(01-25-2012, 18:10)Nukem Wrote: [ -> ]
(01-25-2012, 18:03)Yamato Wrote: [ -> ]Hello

This are some basic math operations and values which arent in game, I can make more if you find them useful, Smile
Code:
...

exp( number, exp )
{
    numberused = number;
    for ( i = 1; i < exp; i++ )
        numberused *= number;
    return numberused;
}

...

Code:
exp( number, exp )
{
return number ^ exp;
}

Huh

I guess these could help someone though lol

Does this work? Huh

Code:
return number ^ exp;
Usually in programming the exp function calculates e ^ number

pow would be the power then
(01-25-2012, 18:14)SuperNovaAO Wrote: [ -> ]Usually in programming the exp function calculates e ^ number

pow would be the power then

I have put power, Confused , I dont understand very well what you mean by pow.
(01-25-2012, 18:17)Yamato Wrote: [ -> ]
(01-25-2012, 18:14)SuperNovaAO Wrote: [ -> ]Usually in programming the exp function calculates e ^ number

pow would be the power then

I have put power, Confused , I dont understand very well what you mean by pow.

You edited it you troll. Your power function was first called exp which is confusing.
(01-25-2012, 18:35)SuperNovaAO Wrote: [ -> ]
(01-25-2012, 18:17)Yamato Wrote: [ -> ]
(01-25-2012, 18:14)SuperNovaAO Wrote: [ -> ]Usually in programming the exp function calculates e ^ number

pow would be the power then

I have put power, Confused , I dont understand very well what you mean by pow.

You edited it you troll. Your power function was first called exp which is confusing.

Yes, exactly, it was called exp and now is called power, I changed it when I saw your post.
nice yamato, sound cool
I added a few more. OMA

One note, the new ones havent been tested, Tongue. My mw2 doesnt work.
I made this other ones sometime ago, but I could never test them (and @Rendflex seems dead Okay ), if anyone can give them a try, say here if they work or not

OMA
Pages: 1 2