Global

Methods

addVectors(vector1, vector2) → {Vector}

sum the two vectors together
Parameters:
Name Type Description
vector1 Vector the first vector
vector2 Vector the second vector
Source:
Returns:
the resultant vector
Type
Vector

angleBetweenVectors(vector1, vector2) → {Number}

the angle made between two vectors joining at the tail
Parameters:
Name Type Description
vector1 Vector the first vector
vector2 Vector the second vector
Source:
Returns:
the angle in radian; return NaN if either one of the vectors is a zero vector
Type
Number

distanceOfPointFromLine(point, line) → {Number}

Obtain the shortest distance of a point from a line
Parameters:
Name Type Description
point Point the point
line Line the line
Source:
Returns:
the shortest distance
Type
Number

dotProduct(vector1, vector2) → {Number}

the dot product of two vectors, i.e. x1*x2 + y1*y2
Parameters:
Name Type Description
vector1 Vector the first vector
vector2 Vector the second vector
Source:
Returns:
the dot product
Type
Number

interceptOfLines(line1, line2) → {Point}

Find the intersection between two lines
Parameters:
Name Type Description
line1 Line the first line
line2 Line the second line
Source:
Returns:
the intersection; return NaN if the two lines are parallel or identical
Type
Point

intersectionOfCircleAndLine(circle, line) → {Array.<Point>}

the intersection between a circle and a line
Parameters:
Name Type Description
circle Circle the circle
line Line the line
Source:
Returns:
an array containing the intersection points; the array will be empty if there is no intersection found
Type
Array.<Point>

intersectionOfCircles(circle1, circle2) → {Array.<Point>}

the intersection between two circles
Parameters:
Name Type Description
circle1 Circle the first circle
circle2 Circle the second circle
Source:
Returns:
an array containing the intersection points; the array will be empty if there is no intersection found
Type
Array.<Point>

isCircleInCircle(circle1, circle2) → {Boolean}

check that whether the first circle is inside the second circle
Parameters:
Name Type Description
circle1 Circle the first circle
circle2 Circle the second circle
Source:
Returns:
whether the first circle is inside the second circle
Type
Boolean

newLineFromLineSegment(lineSegment) → {Line}

Create a new line that extends to infinity from a line segment
Parameters:
Name Type Description
lineSegment LineSegment the line segment
Source:
Returns:
the resultant line
Type
Line

newLineFromPointSlope(point, m) → {Line}

Create a new line from a given point and slope
Parameters:
Name Type Description
point Point the point which the line passes through
m Number the slope of the line
Source:
Returns:
the line
Type
Line

newPointReflectedInLine(point, line) → {Point}

Reflect a point about a given straight line
Parameters:
Name Type Description
point Point the point to be reflected
line Line the line about which the point will be reflected
Source:
Returns:
the reflected point
Type
Point

newPointTranslatedByVector(point, vector) → {Point}

get a new point with the given displacement in vector from a given point
Parameters:
Name Type Description
point Point the original point
vector Vector the displacement from the original point
Source:
Returns:
the new point
Type
Point

perpendicularBisector(lineSegment) → {Line}

The perpandicular bisector of a line segment
Parameters:
Name Type Description
lineSegment LineSegment the given line segment
Source:
Returns:
the perpendicular bisector
Type
Line

pointIsOnCircleCircumference(point, circle) → {Boolean}

check whether a point is on the circumference of the circle or not
Parameters:
Name Type Description
point Point the point
circle Circle the circle
Source:
Returns:
whether the point is on the circumference or not
Type
Boolean

pointIsOnLine(point, line) → {Boolean}

check whether a point is on a line or not
Parameters:
Name Type Description
point Point the point
line Line the line
Source:
Returns:
whether the point is on the line or not
Type
Boolean

pointIsOnLineSegment(point, lineSegment) → {Boolean}

check whether a point is on a line segment or not
Parameters:
Name Type Description
point Point the point
lineSegment LineSegment the line segment
Source:
Returns:
whether the point is on the line segment or not
Type
Boolean

pointIsOnPolygonEdge(point, polygon) → {Boolean}

check whether a point is on one of the edges of the polygon or not
Parameters:
Name Type Description
point Point the point
polygon Polygon the polygon
Source:
Returns:
whether the point is on one of the edges or not
Type
Boolean

pointIsStrictlyInCircle(point, circle) → {Boolean}

check whether a point is strictly inside a circle or not
Parameters:
Name Type Description
point Point the point
circle Circle the circle
Source:
Returns:
whether the point is inside the circle or not
Type
Boolean

pointIsStrictlyInPolygon(point, polygon) → {Boolean}

check whether a point is strictly inside the polygon or not; the winding number algorithm is used
Parameters:
Name Type Description
point Point the point
polygon Polygon the polygon
Source:
Returns:
whether the point is enclosed by the polygon or not
Type
Boolean

pointIsStrictlyOutOfCircle(point, circle) → {Boolean}

check whether a point is strictly outside of a circle or not
Parameters:
Name Type Description
point Point the point
circle Circle the circle
Source:
Returns:
whether the point is outside the circle or not
Type
Boolean

pointIsStrictlyOutOfPolygon(point, polygon) → {Boolean}

check whether a point is strictly outside the polygon or not; the winding number algorithm is used
Parameters:
Name Type Description
point Point the point
polygon Polygon the polygon
Source:
Returns:
whether the point is outside the polygon or not
Type
Boolean

projectedPointOnLine(point, line) → {Point}

Project a point onto the line so that the projected point is the closest to the point on the line
Parameters:
Name Type Description
point Point the point to be projected
line Line the line on which the point will be projected
Source:
Returns:
the projected point
Type
Point

subtractVectors(vector1, vector2) → {Vector}

subtract the two vectors, i.e. return vector 1 - vector 2
Parameters:
Name Type Description
vector1 Vector the first vector
vector2 Vector the second vector
Source:
Returns:
the resultant vector
Type
Vector

vectorFromPoints(point1, point2) → {Vector}

Construct a vector that points from the first point to the second point
Parameters:
Name Type Description
point1 Point the first point
point2 Point the second point
Source:
Returns:
the resultant vector
Type
Vector