Skip to content

Math

Angle between two vectors

vex
// Normalize the vectors first!
float angleBetween ( vector v1; vector v2 ) {
// define up vector
vector up = {0.0, 1.0, 0.0};
float angle = acos(dot(v1, v2));
int firstHalf = sign(dot(v2, cross(up, v1))) >= 0;
angle = firstHalf ? angle : 2 * PI - angle;
return degrees(angle);
}

Math constants : Epsilon

Check /opt/hfs20.0/houdini/vex/include math.h

vex
#define M_TOLERANCE 0.0001