@technobuddha > library > Geometry > Angle
Function: angleBetweenPoints()
ts
function angleBetweenPoints(
a: Cartesian,
b: Cartesian,
options: UnitOptions): number;Defined in: angle-between-points.ts:22
Computes the angle between two points (x1,y1) and (x2,y2). Angle zero points in the +X direction, π/2 radians points in the +Y direction (down) and from there we grow clockwise towards π*2 radians.
Parameters
| Parameter | Type | Description |
|---|---|---|
a | Cartesian | first point. |
b | Cartesian | second. |
options | UnitOptions | see UnitOptions |
Returns
number
Standardized angle of the vector from a to b.
Example
typescript
angleBetweenPoints({ x: 0, y: 0 }, { x: 10, y: 0 }); // 0
angleBetweenPoints({ x: 0, y: 0 }, { x: 10, y: 10 }); // π/4
angleBetweenPoints({ x: 0, y: 0 }, { x: 0, y: 10 }, 'deg'); // 45