Home

# Class goog.math.Vec3

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.

extends goog.math.Coordinate3

Instance Method Summary
| `add(?goog.math.Vec3 b) ⇒ !goog.math.Vec3` Adds another vector to this vector in-place.
| `clone() ⇒ !goog.math.Vec3` Creates a new copy of this Vec3.
| `equals(?goog.math.Vec3 b) ⇒ boolean` Compares this vector with another for equality.
| `invert() ⇒ !goog.math.Vec3` Reverses the sign of the vector. Equivalent to scaling the vector by -1.
| `magnitude() ⇒ number` Returns the magnitude of the vector measured from the origin.
| `normalize() ⇒ !goog.math.Vec3` Normalizes the current vector to have a magnitude of 1.
| `scale(number s) ⇒ !goog.math.Vec3` Scales the current vector by a constant.
| `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.
| `subtract(?goog.math.Vec3 b) ⇒ !goog.math.Vec3` Subtracts another vector from this vector in-place.

Static Method Summary
| `cross(?goog.math.Vec3 a, ?goog.math.Vec3 b) ⇒ !goog.math.Vec3` Returns the cross-product of two vectors.
| `difference(?goog.math.Vec3 a, ?goog.math.Vec3 b) ⇒ !goog.math.Vec3` Returns the difference of two vectors as a new Vec3.
| `dot(?goog.math.Vec3 a, ?goog.math.Vec3 b) ⇒ number` Returns the dot-product of two vectors.
| `fromCoordinate3(?goog.math.Coordinate3 a) ⇒ !goog.math.Vec3` Returns a new Vec3 object from a given coordinate.
| `lerp(?goog.math.Vec3 a, ?goog.math.Vec3 b, number x) ⇒ !goog.math.Vec3` Returns a new Vec3 that is the linear interpolant between vectors a and b at scale-value x.
| `random() ⇒ !goog.math.Vec3` Generates a random vector inside the unit sphere.
| `randomUnit() ⇒ !goog.math.Vec3` Generates a random unit vector. http://mathworld.wolfram.com/SpherePointPicking.html Using (6), (7), and (8) to generate coordinates.
| `sum(?goog.math.Vec3 a, ?goog.math.Vec3 b) ⇒ !goog.math.Vec3` Returns the sum of two vectors as a new Vec3.