@technobuddha/library
Version:
A large library of useful functions
22 lines (21 loc) • 856 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.angleBetweenPoints = void 0;
var normalizeAngle_1 = __importDefault(require("../normalizeAngle"));
/**
* Computes the angle between two points (x1,y1) and (x2,y2).
* Angle zero points in the +X direction, PI/2 radians points in the +Y
* direction (down) and from there we grow clockwise towards PI*2 radians.
*
* @param a first point.
* @param b second.
* @return Standardized angle in radians of the vector from *a* to *b*.
*/
function angleBetweenPoints(a, b) {
return normalizeAngle_1.default(Math.atan2(b.y - a.y, b.x - a.x));
}
exports.angleBetweenPoints = angleBetweenPoints;
exports.default = angleBetweenPoints;