@phun-ky/angle
Version:
A JavaScript function to calculate the angle between two coordinates
25 lines (23 loc) • 992 B
TypeScript
/**
* Returns the angle between two sets of coordinates.
*
* @param {number} cx - The x-coordinate of the first point.
* @param {number} cy - The y-coordinate of the first point.
* @param {number} ex - The x-coordinate of the second point.
* @param {number} ey - The y-coordinate of the second point.
* @param {boolean} [normalize=true] - If the angle output should be normalized to a value between 0° and 360°.
* @throws {SyntaxError} Missing input for `angle`.
* @throws {TypeError} Parameters for `angle` do not have the required type.
* @returns {number} The angle between the given coordinates.
* @example
* ```ts
* // Calculate the angle between two points
* const angleValue = angle(0, 0, 3, 4);
* console.log(angleValue); // 53.13
* // Normalized
* const angleValue = angle(0, 0, -3, -4, true);
* console.log(angleValue); // 233.13
* ```
*/
declare const angle: (cx: number, cy: number, ex: number, ey: number, normalize?: boolean) => number;
export { angle };