Skip to content

API > Vector4


Vector4⚓︎

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

Members⚓︎

Properties⚓︎

Name Description
Vector4.magnitudePropertyReadonly Property Returns the length of this vector (Read Only).
Vector4.normalizedPropertyReadonly Property Returns this vector with a magnitude of 1 (Read Only).
Vector4.sqrMagnitudePropertyReadonly Property Returns the squared length of this vector (Read Only).
Vector4.wProperty W component of the vector.
Vector4.xProperty X component of the vector.
Vector4.yProperty Y component of the vector.
Vector4.zProperty Z component of the vector.

Static Properties⚓︎

Name Description
Vector4.negativeInfinity Static fieldPropertyReadonly Property Shorthand for writing Vector4(-1.#INF,-1.#INF,-1.#INF,-1.#INF).
Vector4.one Static fieldPropertyReadonly Property Shorthand for writing Vector4(1,1,1,1).
Vector4.positiveInfinity Static fieldPropertyReadonly Property Shorthand for writing Vector4(#INF,#INF,#INF,#INF).
Vector4.zero Static fieldPropertyReadonly Property Shorthand for writing Vector4(0,0,0,0).

Constructor⚓︎

Name Description
Vector4(x, y, z, w)Constructor Creates a new vector with given x, y, z, w components.

Methods⚓︎

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

Static Methods⚓︎

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

Operators⚓︎

Name Description
Operator (Vector4-Vector4)Operator Subtracts one vector from another.

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

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

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

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

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

| Operator (Vector4==Vector4)Operator | 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)Operator | Converts a Vector4 to a Vector3. |

| Implicit Cast Operator (Vector2)Operator | 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.