Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
Vector4 Struct
Definition
- Namespace:
- System.Numerics
- Assemblies:
- System.Numerics.dll, System.Numerics.Vectors.dll
- Assemblies:
- netstandard.dll, System.Numerics.Vectors.dll
- Assembly:
- System.Numerics.Vectors.dll
- Assembly:
- System.Numerics.dll
- Assembly:
- netstandard.dll
- Source:
- Vector4.cs
- Source:
- Vector4.cs
- Source:
- Vector4.cs
- Source:
- Vector4.cs
- Source:
- Vector4.cs
Important
Some information relates to prerelease product that may be substantially modified before itβs released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a vector with four single-precision floating-point values.
public value class Vector4 : IEquatable<System::Numerics::Vector4>, IFormattable
public struct Vector4 : IEquatable<System.Numerics.Vector4>, IFormattable
type Vector4 = struct
interface IFormattable
Public Structure Vector4
Implements IEquatable(Of Vector4), IFormattable
- Inheritance
- Implements
Remarks
The Vector4 structure provides support for hardware acceleration.
For matrix transformations, the Vector2, Vector3, and Vector4 instances are represented as rows: a vector v is transformed by a matrix M with vM multiplication.
Constructors
| Name | Description |
|---|---|
| Vector4(ReadOnlySpan<Single>) |
Constructs a vector from the given ReadOnlySpan<T>. The span must contain at least 4 elements. |
| Vector4(Single, Single, Single, Single) |
Creates a vector whose elements have the specified values. |
| Vector4(Single) |
Creates a new Vector4 object whose four elements have the same value. |
| Vector4(Vector2, Single, Single) |
Creates a new Vector4 object from the specified Vector2 object and a Z and a W component. |
| Vector4(Vector3, Single) |
Constructs a new Vector4 object from the specified Vector3 object and a W component. |
Fields
| Name | Description |
|---|---|
| W |
The W component of the vector. |
| X |
The X component of the vector. |
| Y |
The Y component of the vector. |
| Z |
The Z component of the vector. |
Properties
| Name | Description |
|---|---|
| AllBitsSet |
Gets a vector where all bits are set to |
| E |
Gets a vector whose elements are equal to E. |
| Epsilon |
Gets a vector whose elements are equal to Epsilon. |
| Item[Int32] |
Gets or sets the element at the specified index. |
| NaN |
Gets a vector whose elements are equal to NaN. |
| NegativeInfinity |
Gets a vector whose elements are equal to NegativeInfinity. |
| NegativeZero |
Gets a vector whose elements are equal to NegativeZero. |
| One |
Gets a vector whose 4 elements are equal to one. |
| Pi |
Gets a vector whose elements are equal to Pi. |
| PositiveInfinity |
Gets a vector whose elements are equal to PositiveInfinity. |
| Tau |
Gets a vector whose elements are equal to Tau. |
| UnitW |
Gets the vector (0,0,0,1). |
| UnitX |
Gets the vector (1,0,0,0). |
| UnitY |
Gets the vector (0,1,0,0). |
| UnitZ |
Gets the vector (0,0,1,0). |
| Zero |
Gets a vector whose 4 elements are equal to zero. |
Methods
| Name | Description |
|---|---|
| Abs(Vector4) |
Returns a vector whose elements are the absolute values of each of the specified vector's elements. |
| Add(Vector4, Vector4) |
Adds two vectors together. |
| All(Vector4, Single) |
Determines if all elements of a vector are equal to a given value. |
| AllWhereAllBitsSet(Vector4) |
Determines if all elements of a vector have all their bits set. |
| AndNot(Vector4, Vector4) |
Computes the bitwise-and of a given vector and the ones complement of another vector. |
| Any(Vector4, Single) |
Determines if any elements of a vector are equal to a given value. |
| AnyWhereAllBitsSet(Vector4) |
Determines if any elements of a vector have all their bits set. |
| BitwiseAnd(Vector4, Vector4) |
Computes the bitwise-and of two vectors. |
| BitwiseOr(Vector4, Vector4) |
Computes the bitwise-or of two vectors. |
| Clamp(Vector4, Vector4, Vector4) |
Restricts a vector between a minimum and a maximum value. |
| ClampNative(Vector4, Vector4, Vector4) |
Restricts a vector between a minimum and a maximum value using platform specific behavior for |
| ConditionalSelect(Vector4, Vector4, Vector4) |
Conditionally selects a value from two vectors on a bitwise basis. |
| CopySign(Vector4, Vector4) |
Copies the per-element sign of a vector to the per-element sign of another vector. |
| CopyTo(Single[], Int32) |
Copies the elements of the vector to a specified array starting at a specified index position. |
| CopyTo(Single[]) |
Copies the elements of the vector to a specified array. |
| CopyTo(Span<Single>) |
Copies the vector to the given Span<T>. The length of the destination span must be at least 4. |
| Cos(Vector4) |
Computes the cosine of each element in a vector. |
| Count(Vector4, Single) |
Determines the number of elements in a vector that are equal to a given value. |
| CountWhereAllBitsSet(Vector4) |
Determines the number of elements in a vector that have all their bits set. |
| Create(ReadOnlySpan<Single>) |
Constructs a vector from the given ReadOnlySpan<T>. The span must contain at least 4 elements. |
| Create(Single, Single, Single, Single) |
Creates a vector whose elements have the specified values. |
| Create(Single) |
Creates a new Vector4 object whose four elements have the same value. |
| Create(Vector2, Single, Single) |
Creates a new Vector4 object from the specified Vector2 object and a Z and a W component. |
| Create(Vector3, Single) |
Constructs a new Vector4 object from the specified Vector3 object and a W component. |
| CreateScalar(Single) |
Creates a vector with X initialized to the specified value and the remaining elements initialized to zero. |
| CreateScalarUnsafe(Single) |
Creates a vector with X initialized to the specified value and the remaining elements left uninitialized. |
| Cross(Vector4, Vector4) |
Computes the cross product of two vectors. For homogeneous coordinates, the product of the weights is the new weight for the resulting product. |
| DegreesToRadians(Vector4) |
Converts a given vector from degrees to radians. |
| Distance(Vector4, Vector4) |
Computes the Euclidean distance between the two given points. |
| DistanceSquared(Vector4, Vector4) |
Returns the Euclidean distance squared between two specified points. |
| Divide(Vector4, Single) |
Divides the specified vector by a specified scalar value. |
| Divide(Vector4, Vector4) |
Divides the first vector by the second. |
| Dot(Vector4, Vector4) |
Returns the dot product of two vectors. |
| Equals(Object) |
Returns a value that indicates whether this instance and a specified object are equal. |
| Equals(Vector4, Vector4) |
Compares two vectors to determine if they are equal on a per-element basis. |
| Equals(Vector4) |
Returns a value that indicates whether this instance and another vector are equal. |
| EqualsAll(Vector4, Vector4) |
Compares two vectors to determine if all elements are equal. |
| EqualsAny(Vector4, Vector4) |
Compares two vectors to determine if any elements are equal. |
| Exp(Vector4) |
Computes the exponential of each element in a vector. |
| FusedMultiplyAdd(Vector4, Vector4, Vector4) |
Computes ( |
| GetHashCode() |
Returns the hash code for this instance. |
| GreaterThan(Vector4, Vector4) |
Compares two vectors to determine which is greater on a per-element basis. |
| GreaterThanAll(Vector4, Vector4) |
Compares two vectors to determine if all elements are greater. |
| GreaterThanAny(Vector4, Vector4) |
Compares two vectors to determine if any elements are greater. |
| GreaterThanOrEqual(Vector4, Vector4) |
Compares two vectors to determine which is greater or equal on a per-element basis. |
| GreaterThanOrEqualAll(Vector4, Vector4) |
Compares two vectors to determine if all elements are greater or equal. |
| GreaterThanOrEqualAny(Vector4, Vector4) |
Compares two vectors to determine if any elements are greater or equal. |
| Hypot(Vector4, Vector4) |
Computes the hypotenuse given two vectors representing the lengths of the shorter sides in a right-angled triangle. |
| IndexOf(Vector4, Single) |
Determines the index of the first element in a vector that is equal to a given value. |
| IndexOfWhereAllBitsSet(Vector4) |
Determines the index of the first element in a vector that has all bits set. |
| IsEvenInteger(Vector4) |
Determines which elements in a vector are even integral values. |
| IsFinite(Vector4) |
Determines which elements in a vector are finite. |
| IsInfinity(Vector4) |
Determines which elements in a vector are infinity. |
| IsInteger(Vector4) |
Determines which elements in a vector are integral values. |
| IsNaN(Vector4) |
Determines which elements in a vector are NaN. |
| IsNegative(Vector4) |
Determines which elements in a vector represents negative real numbers. |
| IsNegativeInfinity(Vector4) |
Determines which elements in a vector are negative infinity. |
| IsNormal(Vector4) |
Determines which elements in a vector are normal. |
| IsOddInteger(Vector4) |
Determines which elements in a vector are odd integral values. |
| IsPositive(Vector4) |
Determines which elements in a vector represents positive real numbers. |
| IsPositiveInfinity(Vector4) |
Determines which elements in a vector are positive infinity. |
| IsSubnormal(Vector4) |
Determines which elements in a vector are subnormal. |
| IsZero(Vector4) |
Determines which elements in a vector are zero. |
| LastIndexOf(Vector4, Single) |
Determines the index of the last element in a vector that is equal to a given value. |
| LastIndexOfWhereAllBitsSet(Vector4) |
Determines the index of the last element in a vector that has all bits set. |
| Length() |
Returns the length of this vector object. |
| LengthSquared() |
Returns the length of the vector squared. |
| Lerp(Vector4, Vector4, Single) |
Performs a linear interpolation between two vectors based on the given weighting. |
| Lerp(Vector4, Vector4, Vector4) |
Performs a linear interpolation between two vectors based on the given weighting. |
| LessThan(Vector4, Vector4) |
Compares two vectors to determine which is less on a per-element basis. |
| LessThanAll(Vector4, Vector4) |
Compares two vectors to determine if all elements are less. |
| LessThanAny(Vector4, Vector4) |
Compares two vectors to determine if any elements are less. |
| LessThanOrEqual(Vector4, Vector4) |
Compares two vectors to determine which is less or equal on a per-element basis. |
| LessThanOrEqualAll(Vector4, Vector4) |
Compares two vectors to determine if all elements are less or equal. |
| LessThanOrEqualAny(Vector4, Vector4) |
Compares two vectors to determine if any elements are less or equal. |
| Load(Single*) |
Loads a vector from the given source. |
| LoadAligned(Single*) |
Loads a vector from the given aligned source. |
| LoadAlignedNonTemporal(Single*) |
Loads a vector from the given aligned source. |
| LoadUnsafe(Single, UIntPtr) |
Loads a vector from the given source and element offset. |
| LoadUnsafe(Single) |
Loads a vector from the given source. |
| Log(Vector4) |
Computes the log of each element in a vector. |
| Log2(Vector4) |
Computes the log2 of each element in a vector. |
| Max(Vector4, Vector4) |
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors. |
| MaxMagnitude(Vector4, Vector4) |
Compares two vectors to compute which has the greater magnitude on a per-element basis. |
| MaxMagnitudeNumber(Vector4, Vector4) |
Compares two vectors, on a per-element basis, to compute which has the greater magnitude and returning the other value if an input is |
| MaxNative(Vector4, Vector4) |
Compare two vectors to determine which is greater on a per-element basis using platform specific behavior for |
| MaxNumber(Vector4, Vector4) |
Compares two vectors, on a per-element basis, to compute which is greater and returning the other value if an element is |
| Min(Vector4, Vector4) |
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors. |
| MinMagnitude(Vector4, Vector4) |
Compares two vectors to compute which has the lesser magnitude on a per-element basis. |
| MinMagnitudeNumber(Vector4, Vector4) |
Compares two vectors, on a per-element basis, to compute which has the lesser magnitude and returning the other value if an input is |
| MinNative(Vector4, Vector4) |
Compare two vectors to determine which is lesser on a per-element basis using platform specific behavior for |
| MinNumber(Vector4, Vector4) |
Compares two vectors, on a per-element basis, to compute which is lesser and returning the other value if an element is |
| Multiply(Single, Vector4) |
Multiplies a scalar value by a specified vector. |
| Multiply(Vector4, Single) |
Multiplies a vector by a specified scalar. |
| Multiply(Vector4, Vector4) |
Returns a new vector whose values are the product of each pair of elements in two specified vectors. |
| MultiplyAddEstimate(Vector4, Vector4, Vector4) |
Computes an estimate of ( |
| Negate(Vector4) |
Negates a specified vector. |
| None(Vector4, Single) |
Determines if no elements of a vector are equal to a given value. |
| NoneWhereAllBitsSet(Vector4) |
Determines if no elements of a vector have all their bits set. |
| Normalize(Vector4) |
Returns a vector with the same direction as the specified vector, but with a length of one. |
| OnesComplement(Vector4) |
Computes the ones-complement of a vector. |
| RadiansToDegrees(Vector4) |
Converts a given vector from radians to degrees. |
| Round(Vector4, MidpointRounding) |
Rounds each element in a vector to the nearest integer using the specified rounding mode. |
| Round(Vector4) |
Rounds each element in a vector to the nearest integer using the default rounding mode (ToEven). |
| Shuffle(Vector4, Byte, Byte, Byte, Byte) |
Creates a new vector by selecting values from an input vector using a set of indices. |
| Sin(Vector4) |
Computes the sine of each element in a vector. |
| SinCos(Vector4) |
Computes the sine and cosine of each element in a vector. |
| SquareRoot(Vector4) |
Returns a vector whose elements are the square root of each of a specified vector's elements. |
| Subtract(Vector4, Vector4) |
Subtracts the second vector from the first. |
| Sum(Vector4) |
Computes the sum of all elements in a vector. |
| ToString() |
Returns the string representation of the current instance using default formatting. |
| ToString(String, IFormatProvider) |
Returns the string representation of the current instance using the specified format string to format individual elements and the specified format provider to define culture-specific formatting. |
| ToString(String) |
Returns the string representation of the current instance using the specified format string to format individual elements. |
| Transform(Vector2, Matrix4x4) |
Transforms a two-dimensional vector by a specified 4x4 matrix. |
| Transform(Vector2, Quaternion) |
Transforms a two-dimensional vector by the specified Quaternion rotation value. |
| Transform(Vector3, Matrix4x4) |
Transforms a three-dimensional vector by a specified 4x4 matrix. |
| Transform(Vector3, Quaternion) |
Transforms a three-dimensional vector by the specified Quaternion rotation value. |
| Transform(Vector4, Matrix4x4) |
Transforms a four-dimensional vector by a specified 4x4 matrix. |
| Transform(Vector4, Quaternion) |
Transforms a four-dimensional vector by the specified Quaternion rotation value. |
| Truncate(Vector4) |
Truncates each element in a vector. |
| TryCopyTo(Span<Single>) |
Attempts to copy the vector to the given Span<T>. The length of the destination span must be at least 4. |
| Xor(Vector4, Vector4) |
Computes the exclusive-or of two vectors. |
Operators
| Name | Description |
|---|---|
| Addition(Vector4, Vector4) |
Adds two vectors together. |
| BitwiseAnd(Vector4, Vector4) |
Computes the bitwise-and of two vectors. |
| BitwiseOr(Vector4, Vector4) |
Computes the bitwise-or of two vectors. |
| Division(Vector4, Single) |
Divides the specified vector by a specified scalar value. |
| Division(Vector4, Vector4) |
Divides the first vector by the second. |
| Equality(Vector4, Vector4) |
Returns a value that indicates whether each pair of elements in two specified vectors is equal. |
| ExclusiveOr(Vector4, Vector4) |
Computes the exclusive-or of two vectors. |
| Inequality(Vector4, Vector4) |
Returns a value that indicates whether two specified vectors are not equal. |
| LeftShift(Vector4, Int32) |
Shifts each element of a vector left by the specified amount. |
| Multiply(Single, Vector4) |
Multiples the scalar value by the specified vector. |
| Multiply(Vector4, Single) |
Multiples the specified vector by the specified scalar value. |
| Multiply(Vector4, Vector4) |
Returns a new vector whose values are the product of each pair of elements in two specified vectors. |
| OnesComplement(Vector4) |
Computes the ones-complement of a vector. |
| RightShift(Vector4, Int32) |
Shifts (signed) each element of a vector right by the specified amount. |
| Subtraction(Vector4, Vector4) |
Subtracts the second vector from the first. |
| UnaryNegation(Vector4) |
Negates the specified vector. |
| UnaryPlus(Vector4) |
Returns a given vector unchanged. |
| UnsignedRightShift(Vector4, Int32) |
Shifts (unsigned) each element of a vector right by the specified amount. |
Extension Methods
| Name | Description |
|---|---|
| AsPlane(Vector4) | |
| AsQuaternion(Vector4) |
Reinterprets a Vector4 as a new Quaternion. |
| AsVector128(Vector4) |
Reinterprets a Vector4 as a new Vector128<T>. |
| AsVector2(Vector4) | |
| AsVector3(Vector4) | |
| ExtractMostSignificantBits(Vector4) |
Extracts the most significant bit from each element in a vector. |
| GetElement(Vector4, Int32) |
Gets the element at the specified index. |
| Store(Vector4, Single*) |
Stores a vector at the given destination. |
| StoreAligned(Vector4, Single*) |
Stores a vector at the given 16-byte aligned destination. |
| StoreAlignedNonTemporal(Vector4, Single*) |
Stores a vector at the given 16-byte aligned destination. |
| StoreUnsafe(Vector4, Single, UIntPtr) |
Stores a vector at the given destination. |
| StoreUnsafe(Vector4, Single) |
Stores a vector at the given destination. |
| ToScalar(Vector4) |
Converts the given vector to a scalar containing the value of the first element. |
| WithElement(Vector4, Int32, Single) |
Creates a new Vector128<T> with the element at the specified index set to the specified value and the remaining elements set to the same value as that in the given vector. |
Applies to
Feedback
Was this page helpful?
