Class: Point

Point

A point, represented by its cartesian coordinates.

Constructor

new Point(a, b)

Constructs a point of cartesian coordinates (x=a, y=b).
Parameters:
Name Type Description
a number
b number
Source:

Members

x

Returns the horizontal coordinate of the cartesian coordinates.
Source:

y

Returns the vertical coordinate of the cartesian coordinates.
Source:

Methods

add(other) → {Point}

Returns a new point that is the sum.
Parameters:
Name Type Description
other Point
Source:
Returns:
Type
Point

compare(other) → {number}

Compare two points before with x coordinate and maybe after with y coordinate.
Parameters:
Name Type Description
other Point
Source:
Returns:
-1, 0 or 1
Type
number

distance(other) → {number}

Returns the distance between the two points.
Parameters:
Name Type Description
other Point
Source:
Returns:
>= 0
Type
number

distanceSqr(other) → {number}

Returns the square of the distance between the two points.
Parameters:
Name Type Description
other Point
Source:
Returns:
>= 0
Type
number

distanceTo0() → {number}

Returns the distance to (0, 0).
Source:
Returns:
>= 0
Type
number

distanceTo0Sqr() → {number}

Returns the square of the distance to (0, 0).
Source:
Returns:
>= 0
Type
number

isEquals(other) → {boolean}

Returns true iff the point is equals to the point other, namely iff they are same cartesian coordinates.
Parameters:
Name Type Description
other Point
Source:
Returns:
Type
boolean

mulScalar() → {Point}

Returns a new point multiply by the scalar n.
Source:
Returns:
Type
Point

sub(other) → {Point}

Returns a new point that is the difference.
Parameters:
Name Type Description
other Point
Source:
Returns:
Type
Point

toString() → {String}

Returns a string cartesian representation of the point. Each number is represented with at most precision figures after the decimal point.
Source:
Returns:
Type
String