Skip to content

Limiting rotation

If we need to limit how far we can rotate a vector to avoid intersections, we could use simple properties of the right triangle:

$$ \Huge\alpha = \arcsin\left(\frac{\text{f@ptdist}}{\text{f@pscale}}\right) $$ Where f@ptdist is distance to next vector and f@pscale is length of the vector.

limit angle
VEXpression
matrix3 rot = ident();
float angle = asin(f@ptdist/f@pscale);
angle *= chf("angle_control");
rotate(rot, angle, set(0,0,1));
v@N *= rot;

limit angle