# Point

Class representing a point

## Constructor

#### new Point(x, y)

Point may be constructed by two numbers, or by array of two numbers

Source:
  - classes/point.js, line 13

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | `number` | x-coordinate (float number)
`y` | `number` | y-coordinate (float number)

### Classes

Point

### Members

#### box

Returns bounding box of a point

Source:
  - classes/point.js, line 67

#### x :number

x-coordinate (float number)

Source:
  - classes/point.js, line 24

##### Type:

- `number`

#### y :number

y-coordinate (float number)

Source:
  - classes/point.js, line 29

##### Type:

- `number`

### Methods

#### clone() → {Point}

Return new cloned instance of point

Source:
  - classes/point.js, line 75

##### Returns:

Type:
  `Point`

#### distanceTo(shape) → {number|Segment}

Calculate distance and shortest segment from point to shape and return as array [distance, shortest segment]

Source:
  - classes/point.js, line 189

##### Parameters:

Name | Type | Description
--- | --- | ---
`shape` | `Shape` | Shape of the one of supported types Point, Line, Circle, Segment, Arc, Polygon or Planar Set

##### Returns:

- Type:
    `number`
  distance from point to shape
- Type:
    `Segment`
  shortest segment between point and shape (started at point, ended at shape)

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

Returns true if points are equal up to `Flatten.Utils.DP_TOL` tolerance

Source:
  - classes/point.js, line 88

##### Parameters:

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

##### Returns:

Type:
  `boolean`

#### leftTo(line) → {boolean}

Returns true if point belongs to the "left" semi-plane, which means, point belongs to the same semi plane where line normal vector points to Return false if point belongs to the "right" semi-plane or to the line itself

Source:
  - classes/point.js, line 177

##### Parameters:

Name | Type | Description
--- | --- | ---
`line` | `Line` | Query line

##### Returns:

Type:
  `boolean`

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

Defines predicate "less than" between points. Returns true if the point is less than query points, false otherwise
By definition point1 < point2 if {point1.y < point2.y || point1.y == point2.y && point1.x < point2.x
Numeric values compared with `Flatten.Utils.DP_TOL` tolerance

Source:
  - classes/point.js, line 99

##### Parameters:

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

##### Returns:

Type:
  `boolean`

#### on(shape) → {boolean}

Returns true if point is on a shape, false otherwise

Source:
  - classes/point.js, line 230

##### Parameters:

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

##### Returns:

Type:
  `boolean`

#### projectionOn(line) → {Point}

Returns projection point on given line

Source:
  - classes/point.js, line 158

##### Parameters:

Name | Type | Description
--- | --- | ---
`line` | `Line` | Line this point be projected on

##### Returns:

Type:
  `Point`

#### rotate(angle, centeropt) → {Point}

Returns new point rotated by given angle around given center point. If center point is omitted, rotates around zero point (0,0). Positive value of angle defines rotation in counter clockwise direction, negative angle defines rotation in clockwise clockwise direction

Source:
  - classes/point.js, line 116

##### Parameters:

Name | Type | Attributes | Default | Description
--- | --- | --- | --- | ---
`angle` | `number` |  |  | angle in radians
`center` | `Point` | <optional> | (0,0) | center

##### Returns:

Type:
  `Point`

#### svg(attrs) → {String}

Return string to draw point in svg as circle with radius "r"
Accept any valid attributes of svg elements as svg object Defaults attribues are:
{ r:"3", stroke:"black", strokeWidth:"1", fill:"red" }

Source:
  - classes/point.js, line 278

##### Parameters:

Name | Type | Description
--- | --- | ---
`attrs` | `Object` | Any valid attributes of svg circle element, like "r", "stroke", "strokeWidth", "fill"

##### Returns:

Type:
  `String`

#### toJSON() → {Object}

This method returns an object that defines how data will be serialized when called JSON.stringify() method

Source:
  - classes/point.js, line 261

##### Returns:

Type:
  `Object`

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

Return new point transformed by affine transformation matrix m

Source:
  - classes/point.js, line 148

##### Parameters:

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

##### Returns:

Type:
  `Point`

#### translate(vector) → {Point}

Returns new point translated by given vector. Translation vector may by also defined by a pair of numbers.

Source:
  - classes/point.js, line 130

##### Parameters:

Name | Type | Description
--- | --- | ---
`vector` | `Vector` | Translation vector defined as Flatten.Vector or
`` | `number` | `number` | Translation vector defined as pair of numbers

##### Returns:

Type:
  `Point`