I’m doing a small project that involves placing a small square to designate a 90 angle, as sin and cos are used around the full range of a circle.
When that small square gets close to an axis I don’t want the square to overflow to the other side of the axis. As a result, Math.min doesn’t help here because we’re dealing with negative values too, and I’m wanting the value that’s closer to zero.
Currently I’m using a min magnitude function:
const minMag = (a, b) => Math.min(Math.abs(a), Math.abs(b)) === Math.abs(a)
? a
: b;
Is there a name for what this represents better than minMag? Something else?
For anyone that’s curious, it’s for an animated trig functions graph over at http://codepen.io/pmw57/pen/YqmjgO