The goog.vec.Vec3 Namespace

.AnyType

@typedef
{goog.vec.AnyType}

.Float32

@typedef
{goog.vec.Float32}

.Float64

@typedef
{goog.vec.Float64}

.Number

@typedef
{goog.vec.Number}

.Type

@typedef
{Float32Array}

.Vec3Like

@typedef
{goog.vec.ArrayType}

.add(vec0, vec1, resultVec)

Performs a component-wise addition of vec0 and vec1 together storing the result into resultVec.

vec0 {goog.vec.Vec3.AnyType}
The first addend.
vec1 {goog.vec.Vec3.AnyType}
The second addend.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the result. May be vec0 or vec1.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.cloneFloat32

Creates a clone of the given 3 element Float32 vector.

vec {goog.vec.Vec3.Float32}
The source 3 element vector.
returns {!goog.vec.Vec3.Float32}
The new cloned vector.

.cloneFloat64

Creates a clone of the given 3 element vector.

vec {goog.vec.Vec3.Float64}
The source 3 element vector.
returns {!goog.vec.Vec3.Float64}
The new cloned vector.

.createFloat32()

Creates a 3 element vector of Float32. The array is initialized to zero.

returns {!goog.vec.Vec3.Float32}
The new 3 element array.

.createFloat32FromArray(vec)

Creates a new 3 element FLoat32 vector initialized with the value from the given array.

vec {goog.vec.Vec3.AnyType}
The source 3 element array.
returns {!goog.vec.Vec3.Float32}
The new 3 element array.

.createFloat32FromValues(v0, v1, v2)

Creates a new 3 element Float32 vector initialized with the supplied values.

v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
returns {!goog.vec.Vec3.Float32}
The new vector.

.createFloat64()

Creates a 3 element vector of Float64. The array is initialized to zero.

returns {!goog.vec.Vec3.Float64}
The new 3 element array.

.createFloat64FromArray(vec)

Creates a new 3 element Float64 vector initialized with the value from the given array.

vec {goog.vec.Vec3.AnyType}
The source 3 element array.
returns {!goog.vec.Vec3.Float64}
The new 3 element array.

.createFloat64FromValues(v0, v1, v2)

Creates a new 3 element Float64 vector initialized with the supplied values.

v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
returns {!goog.vec.Vec3.Float64}
The new vector.

.createNumber()

Creates a 3 element vector of Number. The array is initialized to zero.

returns {!goog.vec.Vec3.Number}
The new 3 element array.

.cross(v0, v1, resultVec)

Computes the vector (cross) product of v0 and v1 storing the result into resultVec.

v0 {goog.vec.Vec3.AnyType}
The first vector.
v1 {goog.vec.Vec3.AnyType}
The second vector.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the results. May be either v0 or v1.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.direction(vec0, vec1, resultVec)

Returns a unit vector pointing from one point to another. If the input points are equal then the result will be all zeros.

vec0 {goog.vec.Vec3.AnyType}
Origin point.
vec1 {goog.vec.Vec3.AnyType}
Target point.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the results (may be vec0 or vec1).
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.distance(vec0, vec1)

Returns the distance between two points.

vec0 {goog.vec.Vec3.AnyType}
First point.
vec1 {goog.vec.Vec3.AnyType}
Second point.
returns {number}
The distance between the points.

.distanceSquared(vec0, vec1)

Returns the squared distance between two points.

vec0 {goog.vec.Vec3.AnyType}
First point.
vec1 {goog.vec.Vec3.AnyType}
Second point.
returns {number}
The squared distance between the points.

.dot(v0, v1)

Returns the scalar product of vectors v0 and v1.

v0 {goog.vec.Vec3.AnyType}
The first vector.
v1 {goog.vec.Vec3.AnyType}
The second vector.
returns {number}
The scalar product.

.equals(v0, v1)

Returns true if the components of v0 are equal to the components of v1.

v0 {goog.vec.Vec3.AnyType}
The first vector.
v1 {goog.vec.Vec3.AnyType}
The second vector.
returns {boolean}
True if the vectors are equal, false otherwise.

.lerp(v0, v1, f, resultVec)

Linearly interpolate from vec0 to v1 according to f. The value of f should be in the range [0..1] otherwise the results are undefined.

v0 {goog.vec.Vec3.AnyType}
The first vector.
v1 {goog.vec.Vec3.AnyType}
The second vector.
f {number}
The interpolation factor.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the results (may be v0 or v1).
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.magnitude(vec0)

Returns the magnitude of the given vector.

vec0 {goog.vec.Vec3.AnyType}
The vector.
returns {number}
The magnitude of the vector.

.magnitudeSquared(vec0)

Returns the magnitudeSquared of the given vector.

vec0 {goog.vec.Vec3.AnyType}
The vector.
returns {number}
The magnitude of the vector.

.negate(vec0, resultVec)

Negates vec0, storing the result into resultVec.

vec0 {goog.vec.Vec3.AnyType}
The vector to negate.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the result. May be vec0.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.normalize(vec0, resultVec)

Normalizes the given vector storing the result into resultVec.

vec0 {goog.vec.Vec3.AnyType}
The vector to normalize.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the result. May be vec0.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.scale(vec0, scalar, resultVec)

Multiplies each component of vec0 with scalar storing the product into resultVec.

vec0 {goog.vec.Vec3.AnyType}
The source vector.
scalar {number}
The value to multiply with each component of vec0.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the result. May be vec0.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.

.setFromArray(vec, values)

Initializes the vector with the given array of values.

vec {goog.vec.Vec3.AnyType}
The vector to receive the values.
values {goog.vec.Vec3.AnyType}
The array of values.
returns {!goog.vec.Vec3.AnyType}
return vec so that operations can be chained together.

.setFromValues(vec, v0, v1, v2)

Initializes the vector with the given values.

vec {goog.vec.Vec3.AnyType}
The vector to receive the values.
v0 {number}
The value for element at index 0.
v1 {number}
The value for element at index 1.
v2 {number}
The value for element at index 2.
returns {!goog.vec.Vec3.AnyType}
return vec so that operations can be chained together.

.subtract(vec0, vec1, resultVec)

Performs a component-wise subtraction of vec1 from vec0 storing the result into resultVec.

vec0 {goog.vec.Vec3.AnyType}
The minuend.
vec1 {goog.vec.Vec3.AnyType}
The subtrahend.
resultVec {goog.vec.Vec3.AnyType}
The vector to receive the result. May be vec0 or vec1.
returns {!goog.vec.Vec3.AnyType}
return resultVec so that operations can be chained together.