Point

Point

new Point(x, y)

The Point constructor
Parameters:
Name Type Description
x Number The x value
y Number The y value

Methods

add(v) → {Point}

Adds a vector to the point.
Parameters:
Name Type Description
v object | Point The vector to add. Must contain an x and a y property.
Returns:
The Point instance
Type
Point

angle(toPoint) → {Number}

Returns the angle in radians of the slope between pt1 and pt2
Parameters:
Name Type Description
toPoint Point
Returns:
angle
Type
Number

clone() → {Point}

Creates and returns a clone of the given instance.
Returns:
The cloned Point
Type
Point

distance(toPoint) → {Number}

Returns the distance between pt1 and pt2.
Parameters:
Name Type Description
toPoint Point
Returns:
distance
Type
Number

divide(f) → {Point}

Divides the point's coords by f
Parameters:
Name Type Description
f Number Divisor
Returns:
The current Point instance
Type
Point

equals(toCompare) → {Boolean}

Checks equality of current instance to another Point instance.
Parameters:
Name Type Description
toCompare object | Point The object or point instance to compare
Returns:
Type
Boolean

multiply(f) → {Point}

Multiplies the point's coords by f
Parameters:
Name Type Description
f Number Multiplier
Returns:
The current Point instance
Type
Point

normalize(length) → {Point}

Scales the line segment between (0,0) and the current point to a set length.
Parameters:
Name Type Description
length Number The scaling value
Returns:
The current Point instance
Type
Point

offset(dx, dy) → {Point}

Offsets the Point object by the specified amount. The value of dx is added to the original value of x to create the new x value. The value of dy is added to the original value of y to create the new y value.
Parameters:
Name Type Description
dx Number The amount by which to offset the horizontal coordinate, x.
dy Number The amount by which to offset the vertical coordinate, y.
Returns:
The current Point instance
Type
Point

subtract(newPoint) → {Point}

Subtracts the coordinates of another point from the coordinates of this point to create a new point.
Parameters:
Name Type Description
newPoint Point The new point.
Returns:
The current Point instance
Type
Point

toArray() → {Array}

Returns a plain array with x and y.
Returns:
an array
Type
Array

toObject() → {Object}

Returns a plain object with x and y.
Returns:
an object
Type
Object

toString() → {String}

Returns a csv (comma seperated values).
Returns:
a csv
Type
String