# Class LineSegment

A 2D line segment

• LineSegment

## Constructors

• #### Parameters

• ##### begin: Vector

The starting point of the line segment

• ##### end: Vector

The ending point of the line segment

## Properties

begin: Vector

The starting point of the line segment

end: Vector

The ending point of the line segment

## Accessors

• get intercept(): number
• Gets the Y-intercept (b) of the line. Will return (+/-)Infinity if there is no intercept.

#### Returns number

• get slope(): number
• Gets the raw slope (m) of the line. Will return (+/-)Infinity for vertical lines.

## Methods

• Tests if a given point is below the line, points in the normal direction above the line are considered above.

#### Returns boolean

• Returns the clip point

#### Parameters

• ##### sideVector: Vector

Vector that traces the line

• ##### length: number

Length to clip along side

#### Returns LineSegment

• Finds a point on the line given only an X or a Y value. Given an X value, the function returns a new point with the calculated Y value and vice-versa.

### Returns

A new point with the other calculated axis value

#### Parameters

• ##### x: number = null

The known X value of the target point

• ##### y: number = null

The known Y value of the target point

#### Returns Vector

• Returns the edge of the line as vector, the length of the vector is the length of the edge

#### Returns Vector

• Returns the length of the line segment in pixels

#### Returns number

• Returns the slope of the line in the form of a vector of length 1

#### Returns Vector

• Whether or not the given point lies on this line. This method is precise by default meaning the point must lie exactly on the line. Adjust threshold to loosen the strictness of the check for floating-point calculations.

#### Returns boolean

• Whether or not the given point lies on this line. This method is precise by default meaning the point must lie exactly on the line. Adjust threshold to loosen the strictness of the check for floating-point calculations.