Skip to content

@technobuddha > library > Geometry > Point

Function: isOnLine()

ts
function isOnLine(
   point: Cartesian, 
   line: LineSegment, 
   options: OnLineOptions): boolean;

Defined in: is-on-line.ts:37

Determines whether a given point lies on a specified line segment or its extension.

Parameters

ParameterTypeDescription
pointCartesianThe Cartesian coordinates of the point to test.
lineLineSegmentThe line segment defined by its endpoints.
optionsOnLineOptionssee OnLineOptions

Returns

boolean

true if the point lies on the line segment (or its extension if extend is true), otherwise false.

Example

typescript
isOnLine({ x: 2, y: 2 }, { x0: 0, y0: 0, x1: 4, y1: 4 }); // true