API > Vector4
Vector4⚓︎
Representation of four-dimensional vectors.
Check out Unity Vector4.
Members⚓︎
Properties⚓︎
Name | Description |
---|---|
Vector4 .magnitude |
Returns the length of this vector (Read Only). |
Vector4 .normalized |
Returns this vector with a magnitude of 1 (Read Only). |
Vector4 .sqrMagnitude |
Returns the squared length of this vector (Read Only). |
Vector4 .w |
W component of the vector. |
Vector4 .x |
X component of the vector. |
Vector4 .y |
Y component of the vector. |
Vector4 .z |
Z component of the vector. |
Static Properties⚓︎
Name | Description |
---|---|
Vector4 .negativeInfinity |
Shorthand for writing Vector4(-1.#INF,-1.#INF,-1.#INF,-1.#INF) . |
Vector4 .one |
Shorthand for writing Vector4(1,1,1,1) . |
Vector4 .positiveInfinity |
Shorthand for writing Vector4(#INF,#INF,#INF,#INF) . |
Vector4 .zero |
Shorthand for writing Vector4(0,0,0,0) . |
Constructor⚓︎
Name | Description |
---|---|
Vector4(x, y, z, w) |
Creates a new vector with given x, y, z, w components. |
Methods⚓︎
Name | Description |
---|---|
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⚓︎
Name | Description |
---|---|
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⚓︎
Name | Description |
---|---|
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.