From 0a298dba9950afda6d773d8a789824312b5ea02f Mon Sep 17 00:00:00 2001 From: Revar Desmera Date: Thu, 26 Dec 2019 21:42:23 -0800 Subject: [PATCH] Added vang() --- vectors.scad | 12 ++++++++++++ version.scad | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/vectors.scad b/vectors.scad index 8b40ac4..b8ec246 100644 --- a/vectors.scad +++ b/vectors.scad @@ -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 diff --git a/version.scad b/version.scad index c87dbf1..2af2bbb 100644 --- a/version.scad +++ b/version.scad @@ -8,7 +8,7 @@ ////////////////////////////////////////////////////////////////////// -BOSL_VERSION = [2,0,64]; +BOSL_VERSION = [2,0,65]; // Section: BOSL Library Version Functions