# Line

Class representing a line

## Constructor

#### new Line(pt, norm)

Line may be constructed by point and normal vector or by two points that a line passes through

Source:
  - classes/line.js, line 17

##### Parameters:

Name | Type | Description
--- | --- | ---
`pt` | `Point` | point that a line passes through
`norm` | `Vector` | `Point` | normal vector to a line or second point a line passes through

### Classes

Line

### Members

#### box

Returns infinite box

Source:
  - classes/line.js, line 122

#### end

Line has no end point

Source:
  - classes/line.js, line 110

#### length

Return positive infinity number as length

Source:
  - classes/line.js, line 116

#### middle

Middle point is undefined

Source:
  - classes/line.js, line 135

#### norm :Vector

Normal vector to a line
Vector is normalized (length == 1)
Direction of the vector is chosen to satisfy inequality norm * p >= 0

Source:
  - classes/line.js, line 36

##### Type:

- `Vector`

#### pt :Point

Point a line passes through

Source:
  - classes/line.js, line 29

##### Type:

- `Point`

#### slope

Slope of the line - angle in radians between line and axe x from 0 to 2PI

Source:
  - classes/line.js, line 141

#### standard

Get coefficients [A,B,C] of a standard line equation in the form Ax + By = C

Source:
  - classes/line.js, line 151

### Methods

#### clone() → {Line}

Return new cloned instance of line

Source:
  - classes/line.js, line 96

##### Returns:

Type:
  `Line`

#### contains(pt) → {boolean}

Returns true if point belongs to line

Source:
  - classes/line.js, line 182

##### Parameters:

Name | Type | Description
--- | --- | ---
`pt` | `Point` | Query point

##### Returns:

Type:
  `boolean`

#### coord(pt) → {number}

Return coordinate of the point that lies on the line in the transformed coordinate system where center is the projection of the point(0,0) to the line and axe y is collinear to the normal vector.
This method assumes that point lies on the line and does not check it

Source:
  - classes/line.js, line 199

##### Parameters:

Name | Type | Description
--- | --- | ---
`pt` | `Point` | point on a line

##### Returns:

Type:
  `number`

#### distanceTo(shape)

Calculate distance and shortest segment from line to shape and returns array [distance, shortest_segment]

Source:
  - classes/line.js, line 248

##### Parameters:

Name | Type | Description
--- | --- | ---
`shape` | `Shape` | Shape of the one of the types Point, Circle, Segment, Arc, Polygon

##### Returns:

#### incidentTo(other_line) → {boolean}

Returns true if incident to other line

Source:
  - classes/line.js, line 173

##### Parameters:

Name | Type | Description
--- | --- | ---
`other_line` | `Line` | line to check

##### Returns:

Type:
  `boolean`

#### intersect(shape) → {Array.<Point>}

Returns array of intersection points

Source:
  - classes/line.js, line 208

##### Parameters:

Name | Type | Description
--- | --- | ---
`shape` | `Shape` | shape to intersect with

##### Returns:

Type:
  `Array.<Point>`

#### parallelTo(other_line) → {boolean}

Return true if parallel or incident to other line

Source:
  - classes/line.js, line 164

##### Parameters:

Name | Type | Description
--- | --- | ---
`other_line` | `Line` | line to check

##### Returns:

Type:
  `boolean`

#### rotate(angle, center)

Return new line rotated by angle

Source:
  - classes/line.js, line 300

##### Parameters:

Name | Type | Description
--- | --- | ---
`angle` | `number` | angle in radians
`center` | `Point` | center of rotation

#### sortPoints(pts) → {Array.<Point>}

Sort given array of points that lay on a line with respect to coordinate on a line The method assumes that points lay on the line and does not check this

Source:
  - classes/line.js, line 325

##### Parameters:

Name | Type | Description
--- | --- | ---
`pts` | `Array.<Point>` | array of points

##### Returns:

Type:
  `Array.<Point>`

new array sorted

#### split(pt) → {MultilineShapes}

Split line with a point or array of points and return array of shapes Assumed (but not checked) that all points lay on the line

Source:
  - classes/line.js, line 283

##### Parameters:

Name | Type | Description
--- | --- | ---
`pt` | `Point` | `Array.<Point>` |

##### Returns:

Type:
  `MultilineShapes`

#### svg(box, attrs)

Return string to draw svg segment representing line inside given box

Source:
  - classes/line.js, line 346

##### Parameters:

Name | Type | Description
--- | --- | ---
`box` | `Box` | Box representing drawing area
`attrs` | `Object` | an object with attributes of svg circle element

#### transform(m) → {Line}

Return new line transformed by affine transformation matrix

Source:
  - classes/line.js, line 312

##### Parameters:

Name | Type | Description
--- | --- | ---
`m` | `Matrix` | affine transformation matrix (a,b,c,d,tx,ty)

##### Returns:

Type:
  `Line`