The goog.math.Coordinate3 Class

goog.math.Coordinate3(opt_x, opt_y, opt_z)

Class for representing coordinates and positions in 3 dimensions.

opt_x {number=}
X coordinate, defaults to 0.
opt_y {number=}
Y coordinate, defaults to 0.
opt_z {number=}
Z coordinate, defaults to 0.

.clone()

Returns a new copy of the coordinate.

returns {!goog.math.Coordinate3}
A clone of this coordinate.

.difference(a, b)

Returns the difference between two coordinates as a new goog.math.Coordinate3.

a {goog.math.Coordinate3}
A Coordinate3.
b {goog.math.Coordinate3}
A Coordinate3.
returns {!goog.math.Coordinate3}
A Coordinate3 representing the difference between {@code a} and {@code b}.

.distance(a, b)

Returns the distance between two coordinates.

a {goog.math.Coordinate3}
A Coordinate3.
b {goog.math.Coordinate3}
A Coordinate3.
returns {number}
The distance between {@code a} and {@code b}.

.equals(a, b)

Compares coordinates for equality.

a {goog.math.Coordinate3}
A Coordinate3.
b {goog.math.Coordinate3}
A Coordinate3.
returns {boolean}
True iff the coordinates are equal, or if both are null.

.fromArray(a)

Converts a three element array into a Coordinate3 object. If the value passed in is not an array, not array-like, or not of the right length, an error is thrown.

a {Array.<number>}
Array of numbers to become a coordinate.
returns {!goog.math.Coordinate3}
A new coordinate from the array values.
@throws
{Error} When the oject passed in is not valid.

.squaredDistance(a, b)

Returns the squared distance between two coordinates. Squared distances can be used for comparisons when the actual value is not required. Performance note: eliminating the square root is an optimization often used in lower-level languages, but the speed difference is not nearly as pronounced in JavaScript (only a few percent.)

a {goog.math.Coordinate3}
A Coordinate3.
b {goog.math.Coordinate3}
A Coordinate3.
returns {number}
The squared distance between {@code a} and {@code b}.

.toArray()

Returns the contents of this coordinate as a 3 value Array.

returns {!Array.<number>}
A new array.

.toString()

Returns a nice string representing the coordinate.

returns {string}
In the form (50, 73, 31).

.x {number}

X-value

.y {number}

Y-value

.z {number}

Z-value