Struct Double2
- Namespace
- Stride.Core.Mathematics
- Assembly
- Stride.Core.Mathematics.dll
Represents a two dimensional mathematical vector with double-precision floats.
[DataContract("double2")]
[DataStyle(DataStyle.Compact)]
public struct Double2 : IEquatable<Double2>, ISpanFormattable, IFormattable- Implements
Constructors
Double2(Vector2)
Initializes a new instance of the Double2 struct.
public Double2(Vector2 v)Parameters
- vVector2
- The Vector2 to construct the Double2 from. 
Double2(double)
Initializes a new instance of the Double2 struct.
public Double2(double value)Parameters
- valuedouble
- The value that will be assigned to all components. 
Double2(double, double)
Initializes a new instance of the Double2 struct.
public Double2(double x, double y)Parameters
- xdouble
- Initial value for the X component of the vector. 
- ydouble
- Initial value for the Y component of the vector. 
Double2(double[])
Initializes a new instance of the Double2 struct.
public Double2(double[] values)Parameters
- valuesdouble[]
- The values to assign to the X and Y components of the vector. This must be an array with two elements. 
Exceptions
- ArgumentNullException
- Thrown when - valuesis- null.
- ArgumentOutOfRangeException
- Thrown when - valuescontains more or less than two elements.
Fields
One
A Double2 with all of its components set to one.
public static readonly Double2 OneField Value
SizeInBytes
The size of the Double2 type, in bytes.
public static readonly int SizeInBytesField Value
UnitX
The X unit Double2 (1, 0).
public static readonly Double2 UnitXField Value
UnitY
The Y unit Double2 (0, 1).
public static readonly Double2 UnitYField Value
X
The X component of the vector.
[DataMember(0)]
public double XField Value
Y
The Y component of the vector.
[DataMember(1)]
public double YField Value
Zero
A Double2 with all of its components set to zero.
public static readonly Double2 ZeroField Value
Properties
IsNormalized
Gets a value indicting whether this instance is normalized.
public readonly bool IsNormalized { get; }Property Value
this[int]
Gets or sets the component at the specified index.
public double this[int index] { readonly get; set; }Parameters
- indexint
- The index of the component to access. Use 0 for the X component and 1 for the Y component. 
Property Value
- double
- The value of the X or Y component, depending on the index. 
Exceptions
- ArgumentOutOfRangeException
- Thrown when the - indexis out of the range [0, 1].
Methods
Add(Double2, Double2)
Adds two vectors.
public static Double2 Add(Double2 left, Double2 right)Parameters
Returns
- Double2
- The sum of the two vectors. 
Add(ref readonly Double2, ref readonly Double2, out Double2)
Adds two vectors.
public static void Add(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first vector to add. 
- rightDouble2
- The second vector to add. 
- resultDouble2
- When the method completes, contains the sum of the two vectors. 
Barycentric(Double2, Double2, Double2, double, double)
Returns a Double2 containing the 2D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static Double2 Barycentric(Double2 value1, Double2 value2, Double2 value3, double amount1, double amount2)Parameters
- value1Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle. 
- value2Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle. 
- value3Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle. 
- amount1double
- Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in - value2).
- amount2double
- Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in - value3).
Returns
Barycentric(ref readonly Double2, ref readonly Double2, ref readonly Double2, double, double, out Double2)
Returns a Double2 containing the 2D Cartesian coordinates of a point specified in Barycentric coordinates relative to a 2D triangle.
public static void Barycentric(ref readonly Double2 value1, ref readonly Double2 value2, ref readonly Double2 value3, double amount1, double amount2, out Double2 result)Parameters
- value1Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle. 
- value2Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle. 
- value3Double2
- A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle. 
- amount1double
- Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in - value2).
- amount2double
- Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in - value3).
- resultDouble2
- When the method completes, contains the 2D Cartesian coordinates of the specified point. 
CatmullRom(Double2, Double2, Double2, Double2, double)
Performs a Catmull-Rom interpolation using the specified positions.
public static Double2 CatmullRom(Double2 value1, Double2 value2, Double2 value3, Double2 value4, double amount)Parameters
- value1Double2
- The first position in the interpolation. 
- value2Double2
- The second position in the interpolation. 
- value3Double2
- The third position in the interpolation. 
- value4Double2
- The fourth position in the interpolation. 
- amountdouble
- Weighting factor. 
Returns
- Double2
- A vector that is the result of the Catmull-Rom interpolation. 
CatmullRom(ref readonly Double2, ref readonly Double2, ref readonly Double2, ref readonly Double2, double, out Double2)
Performs a Catmull-Rom interpolation using the specified positions.
public static void CatmullRom(ref readonly Double2 value1, ref readonly Double2 value2, ref readonly Double2 value3, ref readonly Double2 value4, double amount, out Double2 result)Parameters
- value1Double2
- The first position in the interpolation. 
- value2Double2
- The second position in the interpolation. 
- value3Double2
- The third position in the interpolation. 
- value4Double2
- The fourth position in the interpolation. 
- amountdouble
- Weighting factor. 
- resultDouble2
- When the method completes, contains the result of the Catmull-Rom interpolation. 
Clamp(Double2, Double2, Double2)
Restricts a value to be within a specified range.
public static Double2 Clamp(Double2 value, Double2 min, Double2 max)Parameters
Returns
- Double2
- The clamped value. 
Clamp(ref readonly Double2, ref readonly Double2, ref readonly Double2, out Double2)
Restricts a value to be within a specified range.
public static void Clamp(ref readonly Double2 value, ref readonly Double2 min, ref readonly Double2 max, out Double2 result)Parameters
- valueDouble2
- The value to clamp. 
- minDouble2
- The minimum value. 
- maxDouble2
- The maximum value. 
- resultDouble2
- When the method completes, contains the clamped value. 
Deconstruct(out double, out double)
Deconstructs the vector's components into named variables.
public readonly void Deconstruct(out double x, out double y)Parameters
Demodulate(Double2, Double2)
Demodulates a vector with another by performing component-wise division.
public static Double2 Demodulate(Double2 left, Double2 right)Parameters
Returns
- Double2
- The demodulated vector. 
Demodulate(ref readonly Double2, ref readonly Double2, out Double2)
Demodulates a vector with another by performing component-wise division.
public static void Demodulate(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first vector to demodulate. 
- rightDouble2
- The second vector to demodulate. 
- resultDouble2
- When the method completes, contains the demodulated vector. 
Distance(Double2, Double2)
Calculates the distance between two vectors.
public static double Distance(Double2 value1, Double2 value2)Parameters
Returns
- double
- The distance between the two vectors. 
Remarks
DistanceSquared(Double2, Double2) may be preferred when only the relative distance is needed and speed is of the essence.
Distance(ref readonly Double2, ref readonly Double2, out double)
Calculates the distance between two vectors.
public static void Distance(ref readonly Double2 value1, ref readonly Double2 value2, out double result)Parameters
- value1Double2
- The first vector. 
- value2Double2
- The second vector. 
- resultdouble
- When the method completes, contains the distance between the two vectors. 
Remarks
DistanceSquared(ref readonly Double2, ref readonly Double2, out double) may be preferred when only the relative distance is needed and speed is of the essence.
DistanceSquared(Double2, Double2)
Calculates the squared distance between two vectors.
public static double DistanceSquared(Double2 value1, Double2 value2)Parameters
Returns
- double
- The squared distance between the two vectors. 
Remarks
Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.
DistanceSquared(ref readonly Double2, ref readonly Double2, out double)
Calculates the squared distance between two vectors.
public static void DistanceSquared(ref readonly Double2 value1, ref readonly Double2 value2, out double result)Parameters
- value1Double2
- The first vector. 
- value2Double2
- The second vector 
- resultdouble
- When the method completes, contains the squared distance between the two vectors. 
Remarks
Distance squared is the value before taking the square root. Distance squared can often be used in place of distance if relative comparisons are being made. For example, consider three points A, B, and C. To determine whether B or C is further from A, compare the distance between A and B to the distance between A and C. Calculating the two distances involves two square roots, which are computationally expensive. However, using distance squared provides the same information and avoids calculating two square roots.
Divide(Double2, double)
Scales a vector by the given value.
public static Double2 Divide(Double2 value, double scale)Parameters
Returns
- Double2
- The scaled vector. 
Divide(ref readonly Double2, double, out Double2)
Scales a vector by the given value.
public static void Divide(ref readonly Double2 value, double scale, out Double2 result)Parameters
- valueDouble2
- The vector to scale. 
- scaledouble
- The amount by which to scale the vector. 
- resultDouble2
- When the method completes, contains the scaled vector. 
Dot(Double2, Double2)
Calculates the dot product of two vectors.
public static double Dot(Double2 left, Double2 right)Parameters
Returns
- double
- The dot product of the two vectors. 
Dot(ref readonly Double2, ref readonly Double2, out double)
Calculates the dot product of two vectors.
public static void Dot(ref readonly Double2 left, ref readonly Double2 right, out double result)Parameters
- leftDouble2
- First source vector. 
- rightDouble2
- Second source vector. 
- resultdouble
- When the method completes, contains the dot product of the two vectors. 
Equals(Double2)
Determines whether the specified Double2 is equal to this instance.
public readonly bool Equals(Double2 other)Parameters
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? value)Parameters
- valueobject
- The object to compare with this instance. 
Returns
- bool
- trueif the specified object is equal to this instance; otherwise,- false.
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()Returns
- int
- A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
Hermite(Double2, Double2, Double2, Double2, double)
Performs a Hermite spline interpolation.
public static Double2 Hermite(Double2 value1, Double2 tangent1, Double2 value2, Double2 tangent2, double amount)Parameters
- value1Double2
- First source position vector. 
- tangent1Double2
- First source tangent vector. 
- value2Double2
- Second source position vector. 
- tangent2Double2
- Second source tangent vector. 
- amountdouble
- Weighting factor. 
Returns
- Double2
- The result of the Hermite spline interpolation. 
Hermite(ref readonly Double2, ref readonly Double2, ref readonly Double2, ref readonly Double2, double, out Double2)
Performs a Hermite spline interpolation.
public static void Hermite(ref readonly Double2 value1, ref readonly Double2 tangent1, ref readonly Double2 value2, ref readonly Double2 tangent2, double amount, out Double2 result)Parameters
- value1Double2
- First source position vector. 
- tangent1Double2
- First source tangent vector. 
- value2Double2
- Second source position vector. 
- tangent2Double2
- Second source tangent vector. 
- amountdouble
- Weighting factor. 
- resultDouble2
- When the method completes, contains the result of the Hermite spline interpolation. 
Length()
Calculates the length of the vector.
public readonly double Length()Returns
- double
- The length of the vector. 
Remarks
LengthSquared() may be preferred when only the relative length is needed and speed is of the essence.
LengthSquared()
Calculates the squared length of the vector.
public readonly double LengthSquared()Returns
- double
- The squared length of the vector. 
Remarks
This method may be preferred to Length() when only a relative length is needed and speed is of the essence.
Lerp(Double2, Double2, double)
Performs a linear interpolation between two vectors.
public static Double2 Lerp(Double2 start, Double2 end, double amount)Parameters
- startDouble2
- Start vector. 
- endDouble2
- End vector. 
- amountdouble
- Value between 0 and 1 indicating the weight of - end.
Returns
- Double2
- The linear interpolation of the two vectors. 
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
Lerp(ref readonly Double2, ref readonly Double2, double, out Double2)
Performs a linear interpolation between two vectors.
public static void Lerp(ref readonly Double2 start, ref readonly Double2 end, double amount, out Double2 result)Parameters
- startDouble2
- Start vector. 
- endDouble2
- End vector. 
- amountdouble
- Value between 0 and 1 indicating the weight of - end.
- resultDouble2
- When the method completes, contains the linear interpolation of the two vectors. 
Remarks
This method performs the linear interpolation based on the following formula.
start + (end - start) * amount
Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.
Max(Double2, Double2)
Returns a vector containing the largest components of the specified vectors.
public static Double2 Max(Double2 left, Double2 right)Parameters
Returns
- Double2
- A vector containing the largest components of the source vectors. 
Max(ref readonly Double2, ref readonly Double2, out Double2)
Returns a vector containing the smallest components of the specified vectors.
public static void Max(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first source vector. 
- rightDouble2
- The second source vector. 
- resultDouble2
- When the method completes, contains an new vector composed of the largest components of the source vectors. 
Min(Double2, Double2)
Returns a vector containing the smallest components of the specified vectors.
public static Double2 Min(Double2 left, Double2 right)Parameters
Returns
- Double2
- A vector containing the smallest components of the source vectors. 
Min(ref readonly Double2, ref readonly Double2, out Double2)
Returns a vector containing the smallest components of the specified vectors.
public static void Min(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first source vector. 
- rightDouble2
- The second source vector. 
- resultDouble2
- When the method completes, contains an new vector composed of the smallest components of the source vectors. 
Modulate(Double2, Double2)
Modulates a vector with another by performing component-wise multiplication.
public static Double2 Modulate(Double2 left, Double2 right)Parameters
Returns
- Double2
- The modulated vector. 
Modulate(ref readonly Double2, ref readonly Double2, out Double2)
Modulates a vector with another by performing component-wise multiplication.
public static void Modulate(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first vector to modulate. 
- rightDouble2
- The second vector to modulate. 
- resultDouble2
- When the method completes, contains the modulated vector. 
Multiply(Double2, double)
Scales a vector by the given value.
public static Double2 Multiply(Double2 value, double scale)Parameters
Returns
- Double2
- The scaled vector. 
Multiply(ref readonly Double2, double, out Double2)
Scales a vector by the given value.
public static void Multiply(ref readonly Double2 value, double scale, out Double2 result)Parameters
- valueDouble2
- The vector to scale. 
- scaledouble
- The amount by which to scale the vector. 
- resultDouble2
- When the method completes, contains the scaled vector. 
Negate(Double2)
Reverses the direction of a given vector.
public static Double2 Negate(Double2 value)Parameters
- valueDouble2
- The vector to negate. 
Returns
- Double2
- A vector facing in the opposite direction. 
Negate(ref readonly Double2, out Double2)
Reverses the direction of a given vector.
public static void Negate(ref readonly Double2 value, out Double2 result)Parameters
- valueDouble2
- The vector to negate. 
- resultDouble2
- When the method completes, contains a vector facing in the opposite direction. 
Normalize()
Converts the vector into a unit vector.
public void Normalize()Normalize(Double2)
Converts the vector into a unit vector.
public static Double2 Normalize(Double2 value)Parameters
- valueDouble2
- The vector to normalize. 
Returns
- Double2
- The normalized vector. 
Normalize(ref readonly Double2, out Double2)
Converts the vector into a unit vector.
public static void Normalize(ref readonly Double2 value, out Double2 result)Parameters
- valueDouble2
- The vector to normalize. 
- resultDouble2
- When the method completes, contains the normalized vector. 
Orthogonalize(Double2[], params Double2[])
Orthogonalizes a list of vectors.
public static void Orthogonalize(Double2[] destination, params Double2[] source)Parameters
- destinationDouble2[]
- The list of orthogonalized vectors. 
- sourceDouble2[]
- The list of vectors to orthogonalize. 
Remarks
Orthogonalization is the process of making all vectors orthogonal to each other. This means that any given vector in the list will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
Orthonormalize(Double2[], params Double2[])
Orthonormalizes a list of vectors.
public static void Orthonormalize(Double2[] destination, params Double2[] source)Parameters
- destinationDouble2[]
- The list of orthonormalized vectors. 
- sourceDouble2[]
- The list of vectors to orthonormalize. 
Remarks
Orthonormalization is the process of making all vectors orthogonal to each other and making all vectors of unit length. This means that any given vector will be orthogonal to any other given vector in the list.
Because this method uses the modified Gram-Schmidt process, the resulting vectors tend to be numerically unstable. The numeric stability decreases according to the vectors position in the list so that the first vector is the most stable and the last vector is the least stable.
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
Reflect(Double2, Double2)
Returns the reflection of a vector off a surface that has the specified normal.
public static Double2 Reflect(Double2 vector, Double2 normal)Parameters
Returns
- Double2
- The reflected vector. 
Remarks
Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.
Reflect(ref readonly Double2, ref readonly Double2, out Double2)
Returns the reflection of a vector off a surface that has the specified normal.
public static void Reflect(ref readonly Double2 vector, ref readonly Double2 normal, out Double2 result)Parameters
- vectorDouble2
- The source vector. 
- normalDouble2
- Normal of the surface. 
- resultDouble2
- When the method completes, contains the reflected vector. 
Remarks
Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.
SmoothStep(Double2, Double2, double)
Performs a cubic interpolation between two vectors.
public static Double2 SmoothStep(Double2 start, Double2 end, double amount)Parameters
- startDouble2
- Start vector. 
- endDouble2
- End vector. 
- amountdouble
- Value between 0 and 1 indicating the weight of - end.
Returns
- Double2
- The cubic interpolation of the two vectors. 
SmoothStep(ref readonly Double2, ref readonly Double2, double, out Double2)
Performs a cubic interpolation between two vectors.
public static void SmoothStep(ref readonly Double2 start, ref readonly Double2 end, double amount, out Double2 result)Parameters
- startDouble2
- Start vector. 
- endDouble2
- End vector. 
- amountdouble
- Value between 0 and 1 indicating the weight of - end.
- resultDouble2
- When the method completes, contains the cubic interpolation of the two vectors. 
Subtract(Double2, Double2)
Subtracts two vectors.
public static Double2 Subtract(Double2 left, Double2 right)Parameters
Returns
- Double2
- The difference of the two vectors. 
Subtract(ref readonly Double2, ref readonly Double2, out Double2)
Subtracts two vectors.
public static void Subtract(ref readonly Double2 left, ref readonly Double2 right, out Double2 result)Parameters
- leftDouble2
- The first vector to subtract. 
- rightDouble2
- The second vector to subtract. 
- resultDouble2
- When the method completes, contains the difference of the two vectors. 
ToArray()
Creates an array containing the elements of the vector.
public readonly double[] ToArray()Returns
- double[]
- A two-element array containing the components of the vector. 
ToString()
Returns a string that represents this instance.
public override readonly string ToString()Returns
ToString(string?, IFormatProvider?)
Returns a string that represents this instance.
public readonly string ToString(string? format, IFormatProvider? formatProvider)Parameters
- formatstring
- The format. 
- formatProviderIFormatProvider
- The format provider. 
Returns
Transform(Double2, Matrix)
Transforms a 2D vector by the given Matrix.
public static Double4 Transform(Double2 vector, Matrix transform)Parameters
Returns
Transform(Double2, Quaternion)
Transforms a 2D vector by the given Quaternion rotation.
public static Double2 Transform(Double2 vector, Quaternion rotation)Parameters
- vectorDouble2
- The vector to rotate. 
- rotationQuaternion
- The Quaternion rotation to apply. 
Returns
Transform(ref readonly Double2, ref readonly Matrix, out Double4)
Transforms a 2D vector by the given Matrix.
public static void Transform(ref readonly Double2 vector, ref readonly Matrix transform, out Double4 result)Parameters
- vectorDouble2
- The source vector. 
- transformMatrix
- The transformation Matrix. 
- resultDouble4
- When the method completes, contains the transformed Double4. 
Transform(ref readonly Double2, ref readonly Quaternion, out Double2)
Transforms a 2D vector by the given Quaternion rotation.
public static void Transform(ref readonly Double2 vector, ref readonly Quaternion rotation, out Double2 result)Parameters
- vectorDouble2
- The vector to rotate. 
- rotationQuaternion
- The Quaternion rotation to apply. 
- resultDouble2
- When the method completes, contains the transformed Double4. 
Transform(Double2[], ref readonly Matrix, Double4[])
Transforms an array of 2D vectors by the given Matrix.
public static void Transform(Double2[] source, ref readonly Matrix transform, Double4[] destination)Parameters
- sourceDouble2[]
- The array of vectors to transform. 
- transformMatrix
- The transformation Matrix. 
- destinationDouble4[]
- The array for which the transformed vectors are stored. 
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
Transform(Double2[], ref readonly Quaternion, Double2[])
Transforms an array of vectors by the given Quaternion rotation.
public static void Transform(Double2[] source, ref readonly Quaternion rotation, Double2[] destination)Parameters
- sourceDouble2[]
- The array of vectors to transform. 
- rotationQuaternion
- The Quaternion rotation to apply. 
- destinationDouble2[]
- The array for which the transformed vectors are stored. This array may be the same array as - source.
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
TransformCoordinate(Double2, Matrix)
Performs a coordinate transformation using the given Matrix.
public static Double2 TransformCoordinate(Double2 coordinate, Matrix transform)Parameters
Returns
- Double2
- The transformed coordinates. 
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
TransformCoordinate(ref readonly Double2, ref readonly Matrix, out Double2)
Performs a coordinate transformation using the given Matrix.
public static void TransformCoordinate(ref readonly Double2 coordinate, ref readonly Matrix transform, out Double2 result)Parameters
- coordinateDouble2
- The coordinate vector to transform. 
- transformMatrix
- The transformation Matrix. 
- resultDouble2
- When the method completes, contains the transformed coordinates. 
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
TransformCoordinate(Double2[], ref readonly Matrix, Double2[])
Performs a coordinate transformation on an array of vectors using the given Matrix.
public static void TransformCoordinate(Double2[] source, ref readonly Matrix transform, Double2[] destination)Parameters
- sourceDouble2[]
- The array of coordinate vectors to trasnform. 
- transformMatrix
- The transformation Matrix. 
- destinationDouble2[]
- The array for which the transformed vectors are stored. This array may be the same array as - source.
Remarks
A coordinate transform performs the transformation with the assumption that the w component is one. The four dimensional vector obtained from the transformation operation has each component in the vector divided by the w component. This forces the wcomponent to be one and therefore makes the vector homogeneous. The homogeneous vector is often prefered when working with coordinates as the w component can safely be ignored.
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
TransformNormal(Double2, Matrix)
Performs a normal transformation using the given Matrix.
public static Double2 TransformNormal(Double2 normal, Matrix transform)Parameters
Returns
- Double2
- The transformed normal. 
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
TransformNormal(ref readonly Double2, ref readonly Matrix, out Double2)
Performs a normal transformation using the given Matrix.
public static void TransformNormal(ref readonly Double2 normal, ref readonly Matrix transform, out Double2 result)Parameters
- normalDouble2
- The normal vector to transform. 
- transformMatrix
- The transformation Matrix. 
- resultDouble2
- When the method completes, contains the transformed normal. 
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
TransformNormal(Double2[], ref readonly Matrix, Double2[])
Performs a normal transformation on an array of vectors using the given Matrix.
public static void TransformNormal(Double2[] source, ref readonly Matrix transform, Double2[] destination)Parameters
- sourceDouble2[]
- The array of normal vectors to transform. 
- transformMatrix
- The transformation Matrix. 
- destinationDouble2[]
- The array for which the transformed vectors are stored. This array may be the same array as - source.
Remarks
A normal transform performs the transformation with the assumption that the w component is zero. This causes the fourth row and fourth collumn of the matrix to be unused. The end result is a vector that is not translated, but all other transformation properties apply. This is often prefered for normal vectors as normals purely represent direction rather than location because normal vectors should not be translated.
Exceptions
- ArgumentNullException
- Thrown when - sourceor- destinationis- null.
- ArgumentOutOfRangeException
- Thrown when - destinationis shorter in length than- source.
Operators
operator +(Double2, Double2)
Adds two vectors.
public static Double2 operator +(Double2 left, Double2 right)Parameters
Returns
- Double2
- The sum of the two vectors. 
operator /(Double2, Double2)
Divides a vector by the given vector, component-wise.
public static Double2 operator /(Double2 value, Double2 by)Parameters
Returns
- Double2
- The scaled vector. 
operator /(Double2, double)
Scales a vector by the given value.
public static Double2 operator /(Double2 value, double scale)Parameters
Returns
- Double2
- The scaled vector. 
operator /(double, Double2)
Divides a numerator by a vector.
public static Double2 operator /(double numerator, Double2 value)Parameters
Returns
- Double2
- The scaled vector. 
operator ==(Double2, Double2)
Tests for equality between two objects.
public static bool operator ==(Double2 left, Double2 right)Parameters
Returns
- bool
- trueif- lefthas the same value as- right; otherwise,- false.
explicit operator Double3(Double2)
public static explicit operator Double3(Double2 value)Parameters
- valueDouble2
- The value. 
Returns
- Double3
- The result of the conversion. 
explicit operator Double4(Double2)
public static explicit operator Double4(Double2 value)Parameters
- valueDouble2
- The value. 
Returns
- Double4
- The result of the conversion. 
explicit operator Half2(Double2)
public static explicit operator Half2(Double2 value)Parameters
- valueDouble2
- The value. 
Returns
- Half2
- The result of the conversion. 
explicit operator Vector2(Double2)
public static explicit operator Vector2(Double2 value)Parameters
- valueDouble2
- The value. 
Returns
- Vector2
- The result of the conversion. 
explicit operator Vector2(Double2)
Casts from Stride.Maths to System.Numerics vectors
public static explicit operator Vector2(Double2 v)Parameters
- vDouble2
- Value to cast 
Returns
explicit operator Double2(Half2)
public static explicit operator Double2(Half2 value)Parameters
- valueHalf2
- The value. 
Returns
- Double2
- The result of the conversion. 
implicit operator Double2(Vector2)
public static implicit operator Double2(Vector2 value)Parameters
- valueVector2
- The value. 
Returns
- Double2
- The result of the conversion. 
implicit operator Double2(Vector2)
Casts from System.Numerics to Stride.Maths vectors
public static implicit operator Double2(Vector2 v)Parameters
- vVector2
- Value to cast 
Returns
operator !=(Double2, Double2)
Tests for inequality between two objects.
public static bool operator !=(Double2 left, Double2 right)Parameters
Returns
- bool
- trueif- lefthas a different value than- right; otherwise,- false.
operator *(Double2, Double2)
Modulates a vector with another by performing component-wise multiplication.
public static Double2 operator *(Double2 left, Double2 right)Parameters
Returns
- Double2
- The multiplication of the two vectors. 
operator *(Double2, double)
Scales a vector by the given value.
public static Double2 operator *(Double2 value, double scale)Parameters
Returns
- Double2
- The scaled vector. 
operator *(double, Double2)
Scales a vector by the given value.
public static Double2 operator *(double scale, Double2 value)Parameters
Returns
- Double2
- The scaled vector. 
operator -(Double2, Double2)
Subtracts two vectors.
public static Double2 operator -(Double2 left, Double2 right)Parameters
Returns
- Double2
- The difference of the two vectors. 
operator -(Double2)
Reverses the direction of a given vector.
public static Double2 operator -(Double2 value)Parameters
- valueDouble2
- The vector to negate. 
Returns
- Double2
- A vector facing in the opposite direction. 
operator +(Double2)
Assert a vector (return it unchanged).
public static Double2 operator +(Double2 value)Parameters
- valueDouble2
- The vector to assert (unchange). 
Returns
- Double2
- The asserted (unchanged) vector.