Collection · 14 utilities

Math utilities

Angles and rectangles: small geometric helpers with explicit coordinate conventions and floating-point caveats.

Convert degrees to radians

Multiply by π and divide by 180.

function degreesToRadians(degrees) { return degrees * Math.PI / 180; }math

Check if a rectangle contains another one

Compare corners: a contains b when b’s corners sit inside or on a’s edges.

function contains({ a, b }) { return a.x1 <= b.x1 && a.y1 <= b.y1 && a.x2 >= b.x2 && a.y2 >= b.…math

Check if a point is inside a rectangle

Compare the point with the rectangle’s edges.

function isInside({ point, rect }) { return point.x > rect.left && point.x < rect.right && poin…math

Convert radians to degrees

Multiply by 180 and divide by π.

function radiansToDegrees(radians) { return radians * 180 / Math.PI; }math

Linear scale a number between ranges

Map a value from one range onto another.

function linearScale({ value, inMin, inMax, outMin, outMax }) { return ((value - inMin) * (outM…math

Try a function in the local code lab, then read its limits before using it in an application.

Type two or more characters. Try “duplicate”, “webhook” or “retry”.