Skip to content

@technobuddha > library > Geometry > Angle

Function: angleOfLine() ​

ts
function angleOfLine(line: LineSegment, options: UnitOptions): number;

Defined in: angle-of-line.ts:19

Calculates the angle of a given line segment, relative to the horizontal axis

Parameters ​

ParameterTypeDescription
lineLineSegmentThe line segment for which to calculate the angle.
optionsUnitOptionssee UnitOptions

Returns ​

number

The angle of the line segment in the specified units.

Example ​

ts
angleOfLine({ x0: 0, y0: 0, x1: 10, y1: 10 }); // π/4
angleOfLine({ x0: 0, y0: 0, x1: 10, y1: 10 }, 'degrees'); // 45