kunz Difference between revisions of "Mathematical Functions in VEX"

Difference between revisions of "Mathematical Functions in VEX"

From kunz
Line 31: Line 31:
</syntaxhighlight>
</syntaxhighlight>


 
====== Mathematical Constants ======
<syntaxhighlight lang='C++'>
<syntaxhighlight lang='C++'>
// $HFS/houdini/vex/include/math.h
// $HFS/houdini/vex/include/math.h
 
M_E        2.7182818   // sometimes called the natural number, or Euler's number
M_E        2.7182818
LN10        2.3025850   // natural logarithm of 10
LN10        2.3025850
LN2        0.6931471   // natural logarithm of 2
LN2        0.6931471
LOG10E      0.4342944
LOG10E      0.4342944
LOG2E      1.4426950
LOG2E      1.4426950

Revision as of 21:16, 2 October 2021

y = 0;            // Constant (value remains the same at all points in time)
y = x;            // Linear (value changes at a constant rate over time)
y = pow(x,2);     // Quadratic, same as: y = x*x;
y = pow(x,3);     // Cubic, same as: y = x*x*x;
y = pow(2,x);     // Exponential, these functions grow very rapidly. y = pow(M_E, x); y = exp(x);
y = 1.0/x;        // Reciprocal, with x in the denominator this will produce asymptotes at the axis
y = pow(x,0.5);   // Square Root, same as: y = sqrt(x);
y = log(x);       // Logarithmic, rate of growth diminishes over time
Mathematical Constants
// $HFS/houdini/vex/include/math.h
M_E         2.7182818    // sometimes called the natural number, or Euler's number
LN10        2.3025850    // natural logarithm of 10
LN2         0.6931471    // natural logarithm of 2
LOG10E      0.4342944
LOG2E       1.4426950
PI          3.1415926
M_TWO_PI    6.2831852
PI_2   	    1.5707963
PI_4	    0.7853981
SQRT1_2	    0.7071067
SQRT2	    1.4142135
TOLERANCE   0.0001