Point

new SuperMap3D.Point(x, y)

A standalone point geometry with useful accessor, comparison, and modification methods.
Name Type Description
x Number the x-coordinate. this could be longitude or screen pixels, or any other sort of unit.
y Number the y-coordinate. this could be latitude or screen pixels, or any other sort of unit.
Example:
var point = new Point(-77, 38);

Methods

staticSuperMap3D.Point.convert(a)Point

Construct a point from an array if necessary, otherwise if the input is already a Point, or an unknown type, return it unchanged
Name Type Description
a Array.<Number> | Point | * any kind of input value
Returns:
constructed point, or passed-through value.
Example:
// this
var point = Point.convert([0, 1]);
// is equivalent to
var point = new Point(0, 1);

add(p)Point

Add this point's x & y coordinates to another point, yielding a new point.
Name Type Description
p Point the other point
Returns:
output point

angle()Number

Get the angle from the 0, 0 coordinate to this point, in radians coordinates.
Returns:
angle

angleTo(b)Number

Get the angle from this point to another point, in radians
Name Type Description
b Point the other point
Returns:
angle

angleWith(b)Number

Get the angle between this point and another point, in radians
Name Type Description
b Point the other point
Returns:
angle

clone()Point

Clone this point, returning a new point that can be modified without affecting the old one.
Returns:
the clone

dist(p)Number

Calculate the distance from this point to another point
Name Type Description
p Point the other point
Returns:
distance

distSqr(p)Number

Calculate the distance from this point to another point, without the square root step. Useful if you're comparing relative distances.
Name Type Description
p Point the other point
Returns:
distance

div(k)Point

Divide this point's x & y coordinates by a factor, yielding a new point.
Name Type Description
k Point factor
Returns:
output point

divByPoint(p)Point

Divide this point's x & y coordinates by point, yielding a new point.
Name Type Description
p Point the other point
Returns:
output point

equals(other)boolean

Judge whether this point is equal to another point, returning true or false.
Name Type Description
other Point the other point
Returns:
whether the points are equal

mag()Number

Return the magitude of this point: this is the Euclidean distance from the 0, 0 coordinate to this point's x and y coordinates.
Returns:
magnitude

matMult(m)Point

Multiply this point by a 4x1 transformation matrix
Name Type Description
m Array.<Number> transformation matrix
Returns:
output point

mult(k)Point

Multiply this point's x & y coordinates by a factor, yielding a new point.
Name Type Description
k Point factor
Returns:
output point

multByPoint(p)Point

Multiply this point's x & y coordinates by point, yielding a new point.
Name Type Description
p Point the other point
Returns:
output point

perp()Point

Compute a perpendicular point, where the new y coordinate is the old x coordinate and the new x coordinate is the old y coordinate multiplied by -1
Returns:
perpendicular point

rotate(a)Point

Rotate this point around the 0, 0 origin by an angle a, given in radians
Name Type Description
a Number angle to rotate around, in radians
Returns:
output point

rotateAround(a, p)Point

Rotate this point around p point by an angle a, given in radians
Name Type Description
a Number angle to rotate around, in radians
p Point Point to rotate around
Returns:
output point

round()Point

Return a version of this point with the x & y coordinates rounded to integers.
Returns:
rounded point

sub(p)Point

Subtract this point's x & y coordinates to from point, yielding a new point.
Name Type Description
p Point the other point
Returns:
output point

unit()Point

Calculate this point but as a unit vector from 0, 0, meaning that the distance from the resulting point to the 0, 0 coordinate will be equal to 1 and the angle from the resulting point to the 0, 0 coordinate will be the same as before.
Returns:
unit vector point