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>, IFormattable
- Implements
Constructors
Double2(Vector2)
Initializes a new instance of the Double2 struct.
public Double2(Vector2 v)
Parameters
v
Vector2The Vector2 to construct the Double2 from.
Double2(double)
Initializes a new instance of the Double2 struct.
public Double2(double value)
Parameters
value
doubleThe 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
x
doubleInitial value for the X component of the vector.
y
doubleInitial value for the Y component of the vector.
Double2(double[])
Initializes a new instance of the Double2 struct.
public Double2(double[] values)
Parameters
values
double[]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
values
isnull
.- ArgumentOutOfRangeException
Thrown when
values
contains more or less than two elements.
Fields
One
A Double2 with all of its components set to one.
public static readonly Double2 One
Field Value
SizeInBytes
The size of the Double2 type, in bytes.
public static readonly int SizeInBytes
Field Value
UnitX
The X unit Double2 (1, 0).
public static readonly Double2 UnitX
Field Value
UnitY
The Y unit Double2 (0, 1).
public static readonly Double2 UnitY
Field Value
X
The X component of the vector.
[DataMember(0)]
public double X
Field Value
Y
The Y component of the vector.
[DataMember(1)]
public double Y
Field Value
Zero
A Double2 with all of its components set to zero.
public static readonly Double2 Zero
Field Value
Properties
IsNormalized
Gets a value indicting whether this instance is normalized.
public bool IsNormalized { get; }
Property Value
this[int]
Gets or sets the component at the specified index.
public double this[int index] { get; set; }
Parameters
index
intThe 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
index
is 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 Double2, ref Double2, out Double2)
Adds two vectors.
public static void Add(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first vector to add.
right
Double2The second vector to add.
result
Double2When 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
value1
Double2A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle.
value2
Double2A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle.
value3
Double2A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle.
amount1
doubleBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2
).amount2
doubleBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3
).
Returns
Barycentric(ref Double2, ref Double2, ref 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 Double2 value1, ref Double2 value2, ref Double2 value3, double amount1, double amount2, out Double2 result)
Parameters
value1
Double2A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle.
value2
Double2A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle.
value3
Double2A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle.
amount1
doubleBarycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in
value2
).amount2
doubleBarycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in
value3
).result
Double2When 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
value1
Double2The first position in the interpolation.
value2
Double2The second position in the interpolation.
value3
Double2The third position in the interpolation.
value4
Double2The fourth position in the interpolation.
amount
doubleWeighting factor.
Returns
- Double2
A vector that is the result of the Catmull-Rom interpolation.
CatmullRom(ref Double2, ref Double2, ref Double2, ref Double2, double, out Double2)
Performs a Catmull-Rom interpolation using the specified positions.
public static void CatmullRom(ref Double2 value1, ref Double2 value2, ref Double2 value3, ref Double2 value4, double amount, out Double2 result)
Parameters
value1
Double2The first position in the interpolation.
value2
Double2The second position in the interpolation.
value3
Double2The third position in the interpolation.
value4
Double2The fourth position in the interpolation.
amount
doubleWeighting factor.
result
Double2When 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 Double2, ref Double2, ref Double2, out Double2)
Restricts a value to be within a specified range.
public static void Clamp(ref Double2 value, ref Double2 min, ref Double2 max, out Double2 result)
Parameters
value
Double2The value to clamp.
min
Double2The minimum value.
max
Double2The maximum value.
result
Double2When the method completes, contains the clamped value.
Deconstruct(out double, out double)
Deconstructs the vector's components into named variables.
public 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 Double2, ref Double2, out Double2)
Demodulates a vector with another by performing component-wise division.
public static void Demodulate(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first vector to demodulate.
right
Double2The second vector to demodulate.
result
Double2When 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 Double2, ref Double2, out double)
Calculates the distance between two vectors.
public static void Distance(ref Double2 value1, ref Double2 value2, out double result)
Parameters
value1
Double2The first vector.
value2
Double2The second vector.
result
doubleWhen the method completes, contains the distance between the two vectors.
Remarks
DistanceSquared(ref Double2, ref 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 Double2, ref Double2, out double)
Calculates the squared distance between two vectors.
public static void DistanceSquared(ref Double2 value1, ref Double2 value2, out double result)
Parameters
value1
Double2The first vector.
value2
Double2The second vector
result
doubleWhen 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 Double2, double, out Double2)
Scales a vector by the given value.
public static void Divide(ref Double2 value, double scale, out Double2 result)
Parameters
value
Double2The vector to scale.
scale
doubleThe amount by which to scale the vector.
result
Double2When 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 Double2, ref Double2, out double)
Calculates the dot product of two vectors.
public static void Dot(ref Double2 left, ref Double2 right, out double result)
Parameters
left
Double2First source vector.
right
Double2Second source vector.
result
doubleWhen the method completes, contains the dot product of the two vectors.
Equals(Double2)
Determines whether the specified Double2 is equal to this instance.
public bool Equals(Double2 other)
Parameters
Returns
Equals(object)
Determines whether the specified object is equal to this instance.
public override bool Equals(object value)
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
public override 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
value1
Double2First source position vector.
tangent1
Double2First source tangent vector.
value2
Double2Second source position vector.
tangent2
Double2Second source tangent vector.
amount
doubleWeighting factor.
Returns
- Double2
The result of the Hermite spline interpolation.
Hermite(ref Double2, ref Double2, ref Double2, ref Double2, double, out Double2)
Performs a Hermite spline interpolation.
public static void Hermite(ref Double2 value1, ref Double2 tangent1, ref Double2 value2, ref Double2 tangent2, double amount, out Double2 result)
Parameters
value1
Double2First source position vector.
tangent1
Double2First source tangent vector.
value2
Double2Second source position vector.
tangent2
Double2Second source tangent vector.
amount
doubleWeighting factor.
result
Double2When the method completes, contains the result of the Hermite spline interpolation.
Length()
Calculates the length of the vector.
public 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 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
start
Double2Start vector.
end
Double2End vector.
amount
doubleValue 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 Double2, ref Double2, double, out Double2)
Performs a linear interpolation between two vectors.
public static void Lerp(ref Double2 start, ref Double2 end, double amount, out Double2 result)
Parameters
start
Double2Start vector.
end
Double2End vector.
amount
doubleValue between 0 and 1 indicating the weight of
end
.result
Double2When 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 Double2, ref Double2, out Double2)
Returns a vector containing the smallest components of the specified vectors.
public static void Max(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first source vector.
right
Double2The second source vector.
result
Double2When 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 Double2, ref Double2, out Double2)
Returns a vector containing the smallest components of the specified vectors.
public static void Min(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first source vector.
right
Double2The second source vector.
result
Double2When 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 Double2, ref Double2, out Double2)
Modulates a vector with another by performing component-wise multiplication.
public static void Modulate(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first vector to modulate.
right
Double2The second vector to modulate.
result
Double2When 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 Double2, double, out Double2)
Scales a vector by the given value.
public static void Multiply(ref Double2 value, double scale, out Double2 result)
Parameters
value
Double2The vector to scale.
scale
doubleThe amount by which to scale the vector.
result
Double2When the method completes, contains the scaled vector.
Negate(Double2)
Reverses the direction of a given vector.
public static Double2 Negate(Double2 value)
Parameters
value
Double2The vector to negate.
Returns
- Double2
A vector facing in the opposite direction.
Negate(ref Double2, out Double2)
Reverses the direction of a given vector.
public static void Negate(ref Double2 value, out Double2 result)
Parameters
value
Double2The vector to negate.
result
Double2When 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
value
Double2The vector to normalize.
Returns
- Double2
The normalized vector.
Normalize(ref Double2, out Double2)
Converts the vector into a unit vector.
public static void Normalize(ref Double2 value, out Double2 result)
Parameters
value
Double2The vector to normalize.
result
Double2When 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
destination
Double2[]The list of orthogonalized vectors.
source
Double2[]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
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
Orthonormalize(Double2[], params Double2[])
Orthonormalizes a list of vectors.
public static void Orthonormalize(Double2[] destination, params Double2[] source)
Parameters
destination
Double2[]The list of orthonormalized vectors.
source
Double2[]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
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
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 Double2, ref Double2, out Double2)
Returns the reflection of a vector off a surface that has the specified normal.
public static void Reflect(ref Double2 vector, ref Double2 normal, out Double2 result)
Parameters
vector
Double2The source vector.
normal
Double2Normal of the surface.
result
Double2When 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
start
Double2Start vector.
end
Double2End vector.
amount
doubleValue between 0 and 1 indicating the weight of
end
.
Returns
- Double2
The cubic interpolation of the two vectors.
SmoothStep(ref Double2, ref Double2, double, out Double2)
Performs a cubic interpolation between two vectors.
public static void SmoothStep(ref Double2 start, ref Double2 end, double amount, out Double2 result)
Parameters
start
Double2Start vector.
end
Double2End vector.
amount
doubleValue between 0 and 1 indicating the weight of
end
.result
Double2When 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 Double2, ref Double2, out Double2)
Subtracts two vectors.
public static void Subtract(ref Double2 left, ref Double2 right, out Double2 result)
Parameters
left
Double2The first vector to subtract.
right
Double2The second vector to subtract.
result
Double2When the method completes, contains the difference of the two vectors.
ToArray()
Creates an array containing the elements of the vector.
public double[] ToArray()
Returns
- double[]
A two-element array containing the components of the vector.
ToString()
Returns a string that represents this instance.
public override string ToString()
Returns
ToString(IFormatProvider)
Returns a string that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
formatProvider
IFormatProviderThe format provider.
Returns
ToString(string)
Returns a string that represents this instance.
public string ToString(string format)
Parameters
format
stringThe format.
Returns
ToString(string, IFormatProvider)
Returns a string that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
format
stringThe format.
formatProvider
IFormatProviderThe 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
vector
Double2The vector to rotate.
rotation
QuaternionThe Quaternion rotation to apply.
Returns
Transform(ref Double2, ref Matrix, out Double4)
Transforms a 2D vector by the given Matrix.
public static void Transform(ref Double2 vector, ref Matrix transform, out Double4 result)
Parameters
vector
Double2The source vector.
transform
MatrixThe transformation Matrix.
result
Double4When the method completes, contains the transformed Double4.
Transform(ref Double2, ref Quaternion, out Double2)
Transforms a 2D vector by the given Quaternion rotation.
public static void Transform(ref Double2 vector, ref Quaternion rotation, out Double2 result)
Parameters
vector
Double2The vector to rotate.
rotation
QuaternionThe Quaternion rotation to apply.
result
Double2When the method completes, contains the transformed Double4.
Transform(Double2[], ref Matrix, Double4[])
Transforms an array of 2D vectors by the given Matrix.
public static void Transform(Double2[] source, ref Matrix transform, Double4[] destination)
Parameters
source
Double2[]The array of vectors to transform.
transform
MatrixThe transformation Matrix.
destination
Double4[]The array for which the transformed vectors are stored.
Exceptions
- ArgumentNullException
Thrown when
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
Transform(Double2[], ref Quaternion, Double2[])
Transforms an array of vectors by the given Quaternion rotation.
public static void Transform(Double2[] source, ref Quaternion rotation, Double2[] destination)
Parameters
source
Double2[]The array of vectors to transform.
rotation
QuaternionThe Quaternion rotation to apply.
destination
Double2[]The array for which the transformed vectors are stored. This array may be the same array as
source
.
Exceptions
- ArgumentNullException
Thrown when
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
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 Double2, ref Matrix, out Double2)
Performs a coordinate transformation using the given Matrix.
public static void TransformCoordinate(ref Double2 coordinate, ref Matrix transform, out Double2 result)
Parameters
coordinate
Double2The coordinate vector to transform.
transform
MatrixThe transformation Matrix.
result
Double2When 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 Matrix, Double2[])
Performs a coordinate transformation on an array of vectors using the given Matrix.
public static void TransformCoordinate(Double2[] source, ref Matrix transform, Double2[] destination)
Parameters
source
Double2[]The array of coordinate vectors to trasnform.
transform
MatrixThe transformation Matrix.
destination
Double2[]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
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
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 Double2, ref Matrix, out Double2)
Performs a normal transformation using the given Matrix.
public static void TransformNormal(ref Double2 normal, ref Matrix transform, out Double2 result)
Parameters
normal
Double2The normal vector to transform.
transform
MatrixThe transformation Matrix.
result
Double2When 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 Matrix, Double2[])
Performs a normal transformation on an array of vectors using the given Matrix.
public static void TransformNormal(Double2[] source, ref Matrix transform, Double2[] destination)
Parameters
source
Double2[]The array of normal vectors to transform.
transform
MatrixThe transformation Matrix.
destination
Double2[]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
source
ordestination
isnull
.- ArgumentOutOfRangeException
Thrown when
destination
is shorter in length thansource
.
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
true
ifleft
has the same value asright
; otherwise,false
.
explicit operator Double3(Double2)
public static explicit operator Double3(Double2 value)
Parameters
value
Double2The value.
Returns
- Double3
The result of the conversion.
explicit operator Double4(Double2)
public static explicit operator Double4(Double2 value)
Parameters
value
Double2The value.
Returns
- Double4
The result of the conversion.
explicit operator Half2(Double2)
public static explicit operator Half2(Double2 value)
Parameters
value
Double2The value.
Returns
- Half2
The result of the conversion.
explicit operator Vector2(Double2)
public static explicit operator Vector2(Double2 value)
Parameters
value
Double2The value.
Returns
- Vector2
The result of the conversion.
explicit operator Double2(Half2)
public static explicit operator Double2(Half2 value)
Parameters
value
Half2The value.
Returns
- Double2
The result of the conversion.
implicit operator Double2(Vector2)
public static implicit operator Double2(Vector2 value)
Parameters
value
Vector2The value.
Returns
- Double2
The result of the conversion.
operator !=(Double2, Double2)
Tests for inequality between two objects.
public static bool operator !=(Double2 left, Double2 right)
Parameters
Returns
- bool
true
ifleft
has a different value thanright
; 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
value
Double2The 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
value
Double2The vector to assert (unchange).
Returns
- Double2
The asserted (unchanged) vector.