goog.math.Vec3
Provided By | |
---|---|
Extends |
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.
new Vec3( x, y, z )
Parameters |
|
---|
Instance Methods
this.add( b ) → goog.math.Vec3
goog.math.Vec3
Adds another vector to this vector in-place.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.clone() → goog.math.Vec3
goog.math.Vec3
Creates a new copy of this Vec3.
Overrides | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
this.equals( b ) → boolean
boolean
Compares this vector with another for equality.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.invert() → goog.math.Vec3
goog.math.Vec3
Reverses the sign of the vector. Equivalent to scaling the vector by -1.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.magnitude() → number
number
Returns the magnitude of the vector measured from the origin.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.normalize() → goog.math.Vec3
goog.math.Vec3
Normalizes the current vector to have a magnitude of 1.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.scale( s ) → goog.math.Vec3
goog.math.Vec3
Scales the current vector by a constant.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.squaredMagnitude() → number
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.
Parameters | None. | ||
---|---|---|---|
Returns |
|
this.subtract( b ) → goog.math.Vec3
goog.math.Vec3
Subtracts another vector from this vector in-place.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
this.toString() → string
string
Returns a nice string representing the coordinate.
Defined by | |||
---|---|---|---|
Parameters | None. | ||
Returns |
|
Instance Properties
this.x → number
number
this.y → number
number
this.z → number
number
Static Functions
Vec3.cross( a, b ) → goog.math.Vec3
goog.math.Vec3
Returns the cross-product of two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.difference( a, b ) → goog.math.Vec3
goog.math.Vec3
Returns the difference of two vectors as a new Vec3.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.distance( a, b ) → number
number
Returns the distance between two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.dot( a, b ) → number
number
Returns the dot-product of two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.equals( a, b ) → boolean
boolean
Compares vectors for equality.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.fromCoordinate3( a ) → goog.math.Vec3
goog.math.Vec3
Returns a new Vec3 object from a given coordinate.
Parameters |
| ||||
---|---|---|---|---|---|
Returns |
|
Vec3.lerp( a, b, x ) → goog.math.Vec3
goog.math.Vec3
Returns a new Vec3 that is the linear interpolant between vectors a and b at scale-value x.
Parameters |
| ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.random() → goog.math.Vec3
goog.math.Vec3
Generates a random vector inside the unit sphere.
Parameters | None. | ||
---|---|---|---|
Returns |
|
Vec3.randomUnit() → goog.math.Vec3
goog.math.Vec3
Generates a random unit vector.
http://mathworld.wolfram.com/SpherePointPicking.html Using (6), (7), and (8) to generate coordinates.
Parameters | None. | ||
---|---|---|---|
Returns |
|
Vec3.rescaled( a, s ) → goog.math.Vec3
goog.math.Vec3
Returns a new Vec3 that is a copy of the vector a, but rescaled by a factor s in all dimensions.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.squaredDistance( a, b ) → number
number
Returns the squared distance between two vectors.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|
Vec3.sum( a, b ) → goog.math.Vec3
goog.math.Vec3
Returns the sum of two vectors as a new Vec3.
Parameters |
| ||||||||
---|---|---|---|---|---|---|---|---|---|
Returns |
|