Added vang()

This commit is contained in:
Revar Desmera 2019-12-26 21:42:23 -08:00
parent 0acf0c829c
commit 0a298dba99
2 changed files with 13 additions and 1 deletions

View file

@ -42,6 +42,18 @@ function is_vector(v) = is_list(v) && is_num(v[0]);
function add_scalar(v,s) = [for (x=v) is_list(x)? add_scalar(x,s) : x+s];
// Function: vang()
// Usage:
// theta = vang([X,Y]);
// theta_phi = vang([X,Y,Z]);
// Description:
// Given a 2D vector, returns the angle in degrees counter-clockwise from X+ on the XY plane.
// Given a 3D vector, returns [THETA,PHI] where THETA is the number of degrees counter-clockwise from X+ on the XY plane, and PHI is the number of degrees up from the X+ axis along the XZ plane.
function vang(v) =
len(v)==2? atan2(v.y,v.x) :
let(res=xyz_to_spherical(v)) [res[1], 90-res[2]];
// Function: vmul()
// Description:
// Element-wise vector multiplication. Multiplies each element of vector `v1` by

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,64];
BOSL_VERSION = [2,0,65];
// Section: BOSL Library Version Functions