Creates a new Vector4
The x component
The y component
The z component
The fourth component, defaults to 1
The fourth component, by convention 1 for a position and 0 for a direction
The x component
The y component
The z component
StaticsharedA static Vector4 reset to (0, 0, 0, 1) on every access, for a result used straight away
This vector is shared and temporary. Do not store references to it.
Adds v to this vector
The point to add
The target to write the result into, defaults to this vector
The out point
Adds v * s to this vector
The point to scale and add
The scalar applied to v
The target to write the result into, defaults to this vector
The out point
Computes the angle between this vector and v across all four components
Returns π/2 when either vector has zero length.
The other vector
The angle in radians, from 0 to π
Multiplies this vector by m, w included, without a divide
A position (w = 1) picks up the matrix's translation and a direction (w = 0) doesn't. With a
projection matrix the result is in clip space; divide by w to get x and y from -1 to 1 across
the view.
The matrix to apply
The target to write the result into, defaults to this vector
The out point
Clamps each component of this vector between the matching components of min and max
Assumes min <= max componentwise.
The lower bound per component
The upper bound per component
The target to write the result into, defaults to this vector
The out point
Copies x, y, z, w from the given point into this vector
The point to copy from
Copies this vector's x, y, z, w into the given point
The point to copy into
The given point
Computes the distance from this vector to v across all four components
The point to measure to
Computes the squared distance from this vector to v
Cheaper than Vector4#distanceTo and enough to compare distances.
The point to measure to
Divides each component of this vector by the matching component of v
The point to divide by
The target to write the result into, defaults to this vector
The out point
Divides each component of this vector by the scalar s
The scalar to divide by
The target to write the result into, defaults to this vector
The out point
Computes the dot product of this vector and v
With a plane (nx, ny, nz, d) whose normal has unit length and a point whose w is 1, it's the
point's signed distance from the plane.
The other vector
Checks whether x, y, z and w all match p exactly, with no tolerance
The point to compare against
Reads x, y, z, w from array starting at offset
The source array
Index of the first component in array
Computes the length of this vector across all four components
Computes the squared length of this vector
Cheaper than Vector4#magnitude, since it skips the square root, and enough to compare lengths.
Sets each component to the larger of this vector's and v's
The point to compare against
The target to write the result into, defaults to this vector
The out point
Sets each component to the smaller of this vector's and v's
The point to compare against
The target to write the result into, defaults to this vector
The out point
Multiplies each component of this vector by the matching component of v
The point to multiply by
The target to write the result into, defaults to this vector
The out point
Multiplies each component of this vector by the scalar s
The scalar to multiply by
The target to write the result into, defaults to this vector
The out point
Negates each component of this vector
The target to write the result into, defaults to this vector
The out point
Scales this vector to unit length across all four components
A zero vector stays zero.
The target to write the result into, defaults to this vector
The out point
Scales this vector so its length across all four components equals length
A zero vector stays zero.
The target length
The target to write the result into, defaults to this vector
The out point
Subtracts v from this vector
The point to subtract
The target to write the result into, defaults to this vector
The out point
Writes this vector's values into array starting at offset
The destination array; a new one is allocated when omitted
Index of the first component in array
The destination array
A four-component vector, such as a position with a
w, an RGBA colour or a plane equationMath methods work on all four components, change the vector they're called on and return it; pass an
outpoint last to write the result there instead. Where a method takes a point, any PointData4D works, such as a plain{ x, y, z, w }object.Example