Skip to content

Dihedral function

A dihedral angle is the angle between two intersecting planes/vectors

$$ \Huge\cos\alpha = \frac{\mathbf{A} \cdot \mathbf{B}}{|\mathbf{A}| |\mathbf{B}|} $$

float cosAngle = dot(B, A) / (length(A) * length(B));

Houdini dihedral function implementation can output matrix3 or quaternion.

matrix3  dihedral(vector a, vector b)
vector4  dihedral(vector a, vector b)

This is done using

VEXpression
float cosAngle = dot(B, A) / (length(A) * length(B));
float Angle = acos(cosAngle);
vector Axis = normalize(cross(B, A));

// matrix construction
matrix3 rotationM = ident();
rotate(rotationM, Angle, Axis);
3@transform = rotationM;

// quaternion construction
p@orient = quaternion(Angle, Axis);