mirror of
https://github.com/revarbat/BOSL2.git
synced 2025-01-16 13:50:23 +01:00
Fixed crazy FP rounding error in vector3d_angle()
This commit is contained in:
parent
b6a922295b
commit
924a35188c
@ -207,7 +207,8 @@ function normalize(v) = v/norm(v);
|
||||
function vector2d_angle(v1,v2) = atan2(v1[1],v1[0]) - atan2(v2[1],v2[0]);
|
||||
|
||||
// Returns angle in degrees between two 3D vectors.
|
||||
function vector3d_angle(v1,v2) = acos((v1*v2)/(norm(v1)*norm(v2)));
|
||||
// NOTE: min and max are to correct for crazy FP rounding errors that exceed acos()'s domain.
|
||||
function vector3d_angle(v1,v2) = acos(max(-1,min(1,(v1*v2)/(norm(v1)*norm(v2)))));
|
||||
|
||||
// Returns a slice of an array. An index of 0 is the array start, -1 is array end
|
||||
function slice(arr,st,end) = let(
|
||||
|
Loading…
x
Reference in New Issue
Block a user