math.Vec3 Extends goog.math.Coordinate3
Class for a three-dimensional vector object and assorted functions useful for manipulation. Inherits from goog.math.Coordinate3 so that a Vec3 may be passed in to any function that requires a Coordinate.

Inheritance

Constructor

goog.math.Vec3(xyz)

Parameters

x : number
The x value for the vector.
y : number
The y value for the vector.
z : number
The z value for the vector.

Instance Methods

Public Protected Private
Defined in goog.math.Vec3
add(b) !goog.math.Vec3
Adds another vector to this vector in-place.
Arguments:
b : goog.math.Vec3
The vector to add.
Returns: !goog.math.Vec3  This vector with b added.
code »
clone() !goog.math.Vec3
Creates a new copy of this Vec3.
Returns: !goog.math.Vec3  A new vector with the same coordinates as this one.
code »
equals(b) boolean
Compares this vector with another for equality.
Arguments:
b : goog.math.Vec3
The other vector.
Returns: boolean  True if this vector's x, y and z equal the given vector's x, y, and z, respectively.
code »
invert() !goog.math.Vec3
Reverses the sign of the vector. Equivalent to scaling the vector by -1.
Returns: !goog.math.Vec3  This vector, inverted.
code »
magnitude() number
Returns the magnitude of the vector measured from the origin.
Returns: number  The length of the vector.
code »
normalize() !goog.math.Vec3
Normalizes the current vector to have a magnitude of 1.
Returns: !goog.math.Vec3  This vector, normalized.
code »
scale(s) !goog.math.Vec3
Scales the current vector by a constant.
Arguments:
s : number
The scale factor.
Returns: !goog.math.Vec3  This vector, scaled.
code »
squaredMagnitude() number
Returns the squared magnitude of the vector measured from the origin. NOTE(brenneman): Leaving out the square root is not a significant optimization in JavaScript.
Returns: number  The length of the vector, squared.
code »
subtract(b) !goog.math.Vec3
Subtracts another vector from this vector in-place.
Arguments:
b : goog.math.Vec3
The vector to subtract.
Returns: !goog.math.Vec3  This vector with b subtracted.
code »
clone() !goog.math.Coordinate3
Returns a new copy of the coordinate.
Returns: !goog.math.Coordinate3  A clone of this coordinate.
code »
toArray() !Array.<number>
Returns the contents of this coordinate as a 3 value Array.
Returns: !Array.<number>  A new array.
code »
toString() string
Returns a nice string representing the coordinate.
Returns: string  In the form (50, 73, 31).
code »

Instance Properties

Defined in goog.math.Vec3
constructor :
No description.
Code »
x :
X-value
Code »
y :
Y-value
Code »
z :
Z-value
Code »
x :
X-value
Code »
y :
Y-value
Code »
z :
Z-value
Code »

Static Methods

goog.math.Vec3.cross(ab) !goog.math.Vec3
Returns the cross-product of two vectors.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: !goog.math.Vec3  The cross-product of the two vectors.
code »
goog.math.Vec3.difference(ab) !goog.math.Vec3
Returns the difference of two vectors as a new Vec3.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: !goog.math.Vec3  The difference vector.
code »
goog.math.Vec3.distance(ab) number
Returns the distance between two vectors.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: number  The distance.
code »
goog.math.Vec3.dot(ab) number
Returns the dot-product of two vectors.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: number  The dot-product of the two vectors.
code »
goog.math.Vec3.equals(ab) boolean
Compares vectors for equality.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: boolean  True if the vectors have equal x, y, and z coordinates.
code »
goog.math.Vec3.fromCoordinate3(a) !goog.math.Vec3
Returns a new Vec3 object from a given coordinate.
Arguments:
a : goog.math.Coordinate3
The coordinate.
Returns: !goog.math.Vec3  A new vector object.
code »
goog.math.Vec3.lerp(abx) !goog.math.Vec3
Returns a new Vec3 that is the linear interpolant between vectors a and b at scale-value x.
Arguments:
a : goog.math.Vec3
Vector a.
b : goog.math.Vec3
Vector b.
x : number
The proportion between a and b.
Returns: !goog.math.Vec3  The interpolated vector.
code »
goog.math.Vec3.random() !goog.math.Vec3
Generates a random vector inside the unit sphere.
Returns: !goog.math.Vec3  A random vector.
code »
goog.math.Vec3.randomUnit() !goog.math.Vec3
Generates a random unit vector. http://mathworld.wolfram.com/SpherePointPicking.html Using (6), (7), and (8) to generate coordinates.
Returns: !goog.math.Vec3  A random unit-length vector.
code »
goog.math.Vec3.squaredDistance(ab) number
Returns the squared distance between two vectors.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: number  The squared distance.
code »
goog.math.Vec3.sum(ab) !goog.math.Vec3
Returns the sum of two vectors as a new Vec3.
Arguments:
a : goog.math.Vec3
The first vector.
b : goog.math.Vec3
The second vector.
Returns: !goog.math.Vec3  The sum vector.
code »

Static Properties

goog.math.Vec3.superClass_ :
No description.
Code »

Package math

Package Reference