Struct Vector4
A structure encapsulating four doublevalues and provides hardware accelerated methods.
Inherited Members
Namespace: System.Numerics
Assembly: System.Numerics.dll
Syntax
public struct Vector4Constructors
| Improve this Doc View SourceVector4(Double)
Constructs a vector whose elements are all the single specified value.
Declaration
public Vector4(double value)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | value | The element to fill the vector with. | 
Vector4(Double, Double, Double, Double)
Constructs a vector with the given individual elements.
Declaration
public Vector4(double x, double y, double z, double w)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | x | X component. | 
| Double | y | Y component. | 
| Double | z | Z component. | 
| Double | w | W component. | 
Vector4(Vector2, Double, Double)
Constructs a Vector4 from the given Vector2 and a Z and W component.
Declaration
public Vector4(Vector2 value, double z, double w)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector2 | value | The vector to use as the X and Y components. | 
| Double | z | The Z component. | 
| Double | w | The W component. | 
Vector4(Vector3, Double)
Constructs a Vector4 from the given Vector3 and a W component.
Declaration
public Vector4(Vector3 value, double w)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector3 | value | The vector to use as the X, Y, and Z components. | 
| Double | w | The W component. | 
Fields
| Improve this Doc View SourceW
The W component of the vector.
Declaration
public double WField Value
| Type | Description | 
|---|---|
| Double | 
X
The X component of the vector.
Declaration
public double XField Value
| Type | Description | 
|---|---|
| Double | 
Y
The Y component of the vector.
Declaration
public double YField Value
| Type | Description | 
|---|---|
| Double | 
Z
The Z component of the vector.
Declaration
public double ZField Value
| Type | Description | 
|---|---|
| Double | 
Properties
| Improve this Doc View SourceOne
Returns the vector (1,1,1,1).
Declaration
public static readonly Vector4 One { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
UnitW
Returns the vector (0,0,0,1).
Declaration
public static readonly Vector4 UnitW { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
UnitX
Returns the vector (1,0,0,0).
Declaration
public static readonly Vector4 UnitX { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
UnitY
Returns the vector (0,1,0,0).
Declaration
public static readonly Vector4 UnitY { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
UnitZ
Returns the vector (0,0,1,0).
Declaration
public static readonly Vector4 UnitZ { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
Zero
Returns the vector (0,0,0,0).
Declaration
public static readonly Vector4 Zero { get; }Property Value
| Type | Description | 
|---|---|
| Vector4 | 
Methods
| Improve this Doc View SourceAbs(Vector4)
Returns a vector whose elements are the absolute values of each of the source vector's elements.
Declaration
public static Vector4 Abs(Vector4 value)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The absolute value vector. | 
Add(Vector4, Vector4)
Adds two vectors together.
Declaration
public static Vector4 Add(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The summed vector. | 
Clamp(Vector4, Vector4, Vector4)
Restricts a vector between a min and max value.
Declaration
public static Vector4 Clamp(Vector4 value1, Vector4 min, Vector4 max)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The source vector. | 
| Vector4 | min | The minimum value. | 
| Vector4 | max | The maximum value. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The restricted vector. | 
CopyTo(Double[])
Copies the contents of the vector into the given array.
Declaration
public void CopyTo(double[] array)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | 
CopyTo(Double[], Int32)
Copies the contents of the vector into the given array, starting from index.
Declaration
public void CopyTo(double[] array, int index)Parameters
| Type | Name | Description | 
|---|---|---|
| Double[] | array | |
| Int32 | index | 
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If array is null. | 
| ArgumentOutOfRangeException | If index is greater than end of the array or index is less than zero. | 
| ArgumentException | If number of elements in source vector is greater than those available in destination array. | 
Distance(Vector4, Vector4)
Returns the Euclidean distance between the two given points.
Declaration
public static double Distance(Vector4 value1, Vector4 value2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The first point. | 
| Vector4 | value2 | The second point. | 
Returns
| Type | Description | 
|---|---|
| Double | The distance. | 
DistanceSquared(Vector4, Vector4)
Returns the Euclidean distance squared between the two given points.
Declaration
public static double DistanceSquared(Vector4 value1, Vector4 value2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The first point. | 
| Vector4 | value2 | The second point. | 
Returns
| Type | Description | 
|---|---|
| Double | The distance squared. | 
Divide(Vector4, Double)
Divides the vector by the given scalar.
Declaration
public static Vector4 Divide(Vector4 left, double divisor)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The source vector. | 
| Double | divisor | The scalar value. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The result of the division. | 
Divide(Vector4, Vector4)
Divides the first vector by the second.
Declaration
public static Vector4 Divide(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The vector resulting from the division. | 
Dot(Vector4, Vector4)
Returns the dot product of two vectors.
Declaration
public static double Dot(Vector4 vector1, Vector4 vector2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | vector1 | The first vector. | 
| Vector4 | vector2 | The second vector. | 
Returns
| Type | Description | 
|---|---|
| Double | The dot product. | 
Equals(Vector4)
Returns a boolean indicating whether the given Vector4 is equal to this Vector4 instance.
Declaration
public bool Equals(Vector4 other)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | other | The Vector4 to compare this instance to. | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the other Vector4 is equal to this instance; False otherwise. | 
Equals(Object)
Returns a boolean indicating whether the given Object is equal to this Vector4 instance.
Declaration
public override bool Equals(object obj)Parameters
| Type | Name | Description | 
|---|---|---|
| Object | obj | The Object to compare against. | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the Object is equal to this Vector4; False otherwise. | 
Overrides
| Improve this Doc View SourceGetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()Returns
| Type | Description | 
|---|---|
| Int32 | The hash code. | 
Overrides
| Improve this Doc View SourceLength()
Returns the length of the vector. This operation is cheaper than Length().
Declaration
public double Length()Returns
| Type | Description | 
|---|---|
| Double | The vector's length. | 
LengthSquared()
Returns the length of the vector squared.
Declaration
public double LengthSquared()Returns
| Type | Description | 
|---|---|
| Double | The vector's length squared. | 
Lerp(Vector4, Vector4, Double)
Linearly interpolates between two vectors based on the given weighting.
Declaration
public static Vector4 Lerp(Vector4 value1, Vector4 value2, double amount)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The first source vector. | 
| Vector4 | value2 | The second source vector. | 
| Double | amount | Value between 0 and 1 indicating the weight of the second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The interpolated vector. | 
Max(Vector4, Vector4)
Returns a vector whose elements are the maximum of each of the pairs of elements in the two source vectors.
Declaration
public static Vector4 Max(Vector4 value1, Vector4 value2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The first source vector. | 
| Vector4 | value2 | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The maximized vector. | 
Min(Vector4, Vector4)
Returns a vector whose elements are the minimum of each of the pairs of elements in the two source vectors.
Declaration
public static Vector4 Min(Vector4 value1, Vector4 value2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The first source vector. | 
| Vector4 | value2 | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The minimized vector. | 
Multiply(Double, Vector4)
Multiplies a vector by the given scalar.
Declaration
public static Vector4 Multiply(double left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | left | The scalar value. | 
| Vector4 | right | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The scaled vector. | 
Multiply(Vector4, Double)
Multiplies a vector by the given scalar.
Declaration
public static Vector4 Multiply(Vector4 left, double right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The source vector. | 
| Double | right | The scalar value. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The scaled vector. | 
Multiply(Vector4, Vector4)
Multiplies two vectors together.
Declaration
public static Vector4 Multiply(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The product vector. | 
Negate(Vector4)
Negates a given vector.
Declaration
public static Vector4 Negate(Vector4 value)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The negated vector. | 
Normalize(Vector4)
Returns a vector with the same direction as the given vector, but with a length of 1.
Declaration
public static Vector4 Normalize(Vector4 vector)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | vector | The vector to normalize. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The normalized vector. | 
SquareRoot(Vector4)
Returns a vector whose elements are the square root of each of the source vector's elements.
Declaration
public static Vector4 SquareRoot(Vector4 value)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The square root vector. | 
Subtract(Vector4, Vector4)
Subtracts the second vector from the first.
Declaration
public static Vector4 Subtract(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The difference vector. | 
ToString()
Returns a String representing this Vector4 instance.
Declaration
public override string ToString()Returns
| Type | Description | 
|---|---|
| String | The string representation. | 
Overrides
| Improve this Doc View SourceTransform(Vector2, Quaternion)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static Vector4 Transform(Vector2 value, Quaternion rotation)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector2 | value | The source vector to be rotated. | 
| Quaternion | rotation | The rotation to apply. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The transformed vector. | 
Transform(Vector3, Quaternion)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static Vector4 Transform(Vector3 value, Quaternion rotation)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector3 | value | The source vector to be rotated. | 
| Quaternion | rotation | The rotation to apply. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The transformed vector. | 
Transform(Vector4, Quaternion)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static Vector4 Transform(Vector4 value, Quaternion rotation)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value | The source vector to be rotated. | 
| Quaternion | rotation | The rotation to apply. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The transformed vector. | 
Operators
| Improve this Doc View SourceAddition(Vector4, Vector4)
Adds two vectors together.
Declaration
public static Vector4 operator +(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The summed vector. | 
Division(Vector4, Double)
Divides the vector by the given scalar.
Declaration
public static Vector4 operator /(Vector4 value1, double value2)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value1 | The source vector. | 
| Double | value2 | The scalar value. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The result of the division. | 
Division(Vector4, Vector4)
Divides the first vector by the second.
Declaration
public static Vector4 operator /(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The vector resulting from the division. | 
Equality(Vector4, Vector4)
Returns a boolean indicating whether the two given vectors are equal.
Declaration
public static bool operator ==(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first vector to compare. | 
| Vector4 | right | The second vector to compare. | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the vectors are equal; False otherwise. | 
Inequality(Vector4, Vector4)
Returns a boolean indicating whether the two given vectors are not equal.
Declaration
public static bool operator !=(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first vector to compare. | 
| Vector4 | right | The second vector to compare. | 
Returns
| Type | Description | 
|---|---|
| Boolean | True if the vectors are not equal; False if they are equal. | 
Multiply(Double, Vector4)
Multiplies a vector by the given scalar.
Declaration
public static Vector4 operator *(double left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Double | left | The scalar value. | 
| Vector4 | right | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The scaled vector. | 
Multiply(Vector4, Double)
Multiplies a vector by the given scalar.
Declaration
public static Vector4 operator *(Vector4 left, double right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The source vector. | 
| Double | right | The scalar value. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The scaled vector. | 
Multiply(Vector4, Vector4)
Multiplies two vectors together.
Declaration
public static Vector4 operator *(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The product vector. | 
Subtraction(Vector4, Vector4)
Subtracts the second vector from the first.
Declaration
public static Vector4 operator -(Vector4 left, Vector4 right)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | left | The first source vector. | 
| Vector4 | right | The second source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The difference vector. | 
UnaryNegation(Vector4)
Negates a given vector.
Declaration
public static Vector4 operator -(Vector4 value)Parameters
| Type | Name | Description | 
|---|---|---|
| Vector4 | value | The source vector. | 
Returns
| Type | Description | 
|---|---|
| Vector4 | The negated vector. |