goog.math.Vec3
Classgoog.math.Vec3
> goog.math.Coordinate3
goog.math.Vec3(x, y, z)
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.
x
{number
}
y
{number
}
z
{number
}
.add(b)
Adds another vector to this vector in-place.
b
{goog.math.Vec3
}
goog.math.Vec3
}
.clone()
Creates a new copy of this Vec3.
goog.math.Vec3
}
.cross(a, b)
Returns the cross-product of two vectors.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
goog.math.Vec3
}
.difference(a, b)
Returns the difference of two vectors as a new Vec3.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
goog.math.Vec3
}
.distance
Returns the distance between two vectors.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
number
}
.dot(a, b)
Returns the dot-product of two vectors.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
number
}
.equals(b)
Compares this vector with another for equality.
b
{goog.math.Vec3
}
boolean
}
.fromCoordinate3(a)
Returns a new Vec3 object from a given coordinate.
a
{goog.math.Coordinate3
}
goog.math.Vec3
}
.invert()
Reverses the sign of the vector. Equivalent to scaling the vector by -1.
goog.math.Vec3
}
.lerp(a, b, x)
Returns a new Vec3 that is the linear interpolant between vectors a and b at scale-value x.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
x
{number
}
goog.math.Vec3
}
.magnitude()
Returns the magnitude of the vector measured from the origin.
number
}
.normalize()
Normalizes the current vector to have a magnitude of 1.
goog.math.Vec3
}
.random()
Generates a random vector inside the unit sphere.
goog.math.Vec3
}
.randomUnit()
Generates a random unit vector. http://mathworld.wolfram.com/SpherePointPicking.html Using (6), (7), and (8) to generate coordinates.
goog.math.Vec3
}
.scale(s)
Scales the current vector by a constant.
s
{number
}
goog.math.Vec3
}
.squaredDistance
Returns the squared distance between two vectors.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
number
}
.squaredMagnitude()
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.
number
}
.subtract(b)
Subtracts another vector from this vector in-place.
b
{goog.math.Vec3
}
goog.math.Vec3
}
.sum(a, b)
Returns the sum of two vectors as a new Vec3.
a
{goog.math.Vec3
}
b
{goog.math.Vec3
}
goog.math.Vec3
}
.toArray()
Inherited from goog.math.Coordinate3
.
Returns the contents of this coordinate as a 3 value Array.
Array
.<number
>}
.toString()
Inherited from goog.math.Coordinate3
.
Returns a nice string representing the coordinate.
string
}
.x
{number
}X-value
.y
{number
}Y-value
.z
{number
}Z-value