Options
All
• Public
• Public/Protected
• All

# Class Line

A 2D line segment

• Line

## Constructors

### constructor

• #### Parameters

• ##### begin: Vector

The starting point of the line segment

• ##### end: Vector

The ending point of the line segment

## Properties

### begin

begin: Vector

The starting point of the line segment

### end

end: Vector

The ending point of the line segment

## Accessors

### intercept

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

### slope

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

## Methods

### distanceToPoint

• distanceToPoint(point: Vector): number

### findPoint

• findPoint(x?: number, y?: number): Vector
• 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.

#### Parameters

• ##### Default value x: number = null

The known X value of the target point

• ##### Default value y: number = null

The known Y value of the target point

#### Returns Vector

A new point with the other calculated axis value

### getEdge

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

### getLength

• getLength(): number

### getSlope

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

### hasPoint

• hasPoint(x: number, y: number, threshold?: number): boolean
• hasPoint(v: Vector, threshold?: number): 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.

see

http://stackoverflow.com/a/11908158/109458

#### 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.

see

http://stackoverflow.com/a/11908158/109458