Mathematical Functions in VEX
From kunz
Views
Actions
Namespaces
Variants
Tools
These are some basic parent functions.
Each formula along with some of the characteristics are listed below.
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(2,x); // Exponential, these functions grow very rapidly. y = pow(M_E, x); y = exp(x); y = pow(x,2); // Quadratic, same as: y = x*x; y = pow(x,3); // Cubic, same as: y = x*x*x; y = 1.0/x; // Reciprocal, with x in the denominator this will produce asymptotes at the axis y = log(x); // Logarithmic, rate of growth diminishes over time y = sqrt(x); // Square Root, same as: y = pow(x,0.5);
Mathematical Constants
The following constants are defined in $HFS/houdini/vex/include/math.h and automatically included in all VEX wrangle snippets.
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 // 180° in radians, the ratio of the circumference to diameter of a circle M_TWO_PI 6.2831852 // 360° in radians, the circumference of a unit circle, 2 * PI PI_2 1.5707963 // 90° in radians, 1/4th of the circumference of a unit circle, PI / 2 PI_4 0.7853981 // 45° in radians, 1/8th of the circumference of a unit circle, PI / 4 SQRT1_2 0.7071067 SQRT2 1.4142135 TOLERANCE 0.0001
Here are some curves produced using standard math/VEX functions.
sin wave square wave triangle wave clamp floor frac abs smoothstep
Let's take a look at some practical applications of these functions.
- math #vex