Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Simple Math Commands
#1
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.
Reply

#2
(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
[Image: b_560_95_1.png]
Reply

#3
(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;
Reply

#4
Usually in programming the exp function calculates e ^ number

pow would be the power then
Reply

#5
(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.
Reply

#6
(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.
Reply

#7
(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.
Reply

#8
nice yamato, sound cool
Reply

#9
I added a few more. OMA

One note, the new ones havent been tested, Tongue. My mw2 doesnt work.
Reply

#10
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
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  [Request] Need a plugin that hides all ! Admin commands sylvester123 7 5,260 07-27-2013, 13:21
Last Post: Bandarigoda123
  how to remove commands in the chat ExoGamer* 6 4,452 07-20-2013, 09:24
Last Post: Pozzuh
  [Release] Mw3 Simple External Console barata 25 22,371 06-30-2013, 16:30
Last Post: nexzhd
  Simple flyable helicopter script port, could use help! akillj 0 2,537 06-15-2013, 09:20
Last Post: akillj
  server commands [HARD] Tony. 0 2,080 06-05-2013, 19:44
Last Post: [HARD] Tony.
  Where can I find a list of scripting commands that correspond to ingame buttons? akillj 2 3,114 06-03-2013, 10:38
Last Post: Yamato
  Help Hide commands dhanin 5 4,033 03-28-2013, 00:11
Last Post: Dr3am95
  [Tutorial] Making A Simple Calculator! Ivankec 4 8,779 12-14-2012, 19:22
Last Post: Gam3rr0rZ
  HELP ME WITH COMMANDS schorweg123 4 3,495 10-28-2012, 10:50
Last Post: d0h!
  HELP ME WITH COMMANDS schorweg123 1 2,560 10-28-2012, 10:46
Last Post: d0h!

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.