mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2024-12-29 16:29:40 +00:00
Added modang() to standardize angles to <-180,180>
This commit is contained in:
parent
95952ee971
commit
a85ea4ecc9
1 changed files with 10 additions and 0 deletions
10
math.scad
10
math.scad
|
@ -101,6 +101,7 @@ function min_index(vals, all=false) =
|
||||||
function max_index(vals, all=false) =
|
function max_index(vals, all=false) =
|
||||||
all ? search(max(vals),vals,0) : search(max(vals), vals)[0];
|
all ? search(max(vals),vals,0) : search(max(vals), vals)[0];
|
||||||
|
|
||||||
|
|
||||||
// Function: posmod()
|
// Function: posmod()
|
||||||
// Usage:
|
// Usage:
|
||||||
// posmod(x,m)
|
// posmod(x,m)
|
||||||
|
@ -113,6 +114,15 @@ function max_index(vals, all=false) =
|
||||||
function posmod(x,m) = (x%m+m)%m;
|
function posmod(x,m) = (x%m+m)%m;
|
||||||
|
|
||||||
|
|
||||||
|
// Function: modang(x)
|
||||||
|
// Usage:
|
||||||
|
// ang = modang(x)
|
||||||
|
// Description:
|
||||||
|
// Takes an angle in degrees and normalizes it to an equivalent angle value between -180 and 180.
|
||||||
|
function modang(x) =
|
||||||
|
let(xx = posmod(x,360)) xx<180? xx : xx-360;
|
||||||
|
|
||||||
|
|
||||||
// Function: modrange()
|
// Function: modrange()
|
||||||
// Usage:
|
// Usage:
|
||||||
// modrange(x, y, m, [step])
|
// modrange(x, y, m, [step])
|
||||||
|
|
Loading…
Reference in a new issue