Skip to main content

Vector4

Representation of four-dimensional vectors.
Check out Unity Vector4.

Members

Properties

NameDescription
Vector4.magnitudeReturns the length of this vector (Read Only).
Vector4.normalizedReturns this vector with a magnitude of 1 (Read Only).
Vector4.sqrMagnitudeReturns the squared length of this vector (Read Only).
Vector4.wW component of the vector.
Vector4.xX component of the vector.
Vector4.yY component of the vector.
Vector4.zZ component of the vector.

Static Properties

NameDescription
Vector4.negativeInfinityShorthand for writing Vector4(-1.#INF,-1.#INF,-1.#INF,-1.#INF).
Vector4.oneShorthand for writing Vector4(1,1,1,1).
Vector4.positiveInfinityShorthand for writing Vector4(#INF,#INF,#INF,#INF).
Vector4.zeroShorthand for writing Vector4(0,0,0,0).

Constructor

NameDescription
[Vector4(x, y, z, w)](./Vector4 Constructor.md)Creates a new vector with given x, y, z, w components.

Methods

NameDescription
Vector4.Normalize()Makes this vector have a magnitude of 1.
Vector4.Set(newX, newY, newZ, newW)Set x, y, z and w components of an existing Vector4.

Static Methods

NameDescription
Vector4.Distance(a, b)Returns the distance between a and b.
Vector4.Dot(a, b)Dot Product of two vectors.
Vector4.Lerp(a, b, t)Linearly interpolates between two vectors.
Vector4.LerpUnclamped(a, b, t)Linearly interpolates between two vectors.
Vector4.Max(lhs, rhs)Returns a vector that is made from the largest components of two vectors.
Vector4.Min( lhs, rhs)Returns a vector that is made from the smallest components of two vectors.
Vector4.MoveTowards(current, target, maxDistanceDelta)Moves a point current towards target.
Vector4.Project(a, b)Projects a vector onto another vector.
Vector4.Scale(a, b)Multiplies two vectors component-wise.

Operators

NameDescription
Operator (Vector4-Vector4)Subtracts one vector from another.

| Unary Operator (-Vector4) | Negates a vector. Each component in the result is negated. |

| Operator (Vector4*number) | Multiplies a vector by a number. |

| Operator (number*Vector4) | Multiplies a vector by a number. |

| Operator (Vector4/number) | Divides a vector by a number. |

| Operator (Vector4+Vector4) | Adds two vectors. Adds corresponding components together. |

| Operator (Vector4==Vector4) | Returns true if two vectors are approximately equal. To allow for floating point inaccuracies, the two vectors are considered equal if the magnitude of their difference is less than 1e-5. |

| Implicit Cast Operator (Vector3) | Converts a Vector4 to a Vector3. |

| Implicit Cast Operator (Vector2) | Converts a Vector4 to a Vector2. |

Extra Detail

This structure is used in some places to represent four component vectors (e.g. mesh tangents, parameters for shaders). In the majority of other cases a Vector3 is used.