Double2 Struct
Namespace: Stride.Core.MathematicsAssembly: 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
Name | Description | |
---|---|---|
Constructors | ||
Double2(Vector2) | Initializes a new instance of the Double2 struct. |
|
Double2(Double) | Initializes a new instance of the Double2 struct. |
|
Double2(Double, Double) | Initializes a new instance of the Double2 struct. |
|
Double2(Double[]) | Initializes a new instance of the Double2 struct. |
|
Fields | ||
One | A Double2 with all of its components set to one. |
|
SizeInBytes | The size of the Double2 type, in bytes. |
|
UnitX | The X unit Double2 (1, 0). |
|
UnitY | The Y unit Double2 (0, 1). |
|
X | The X component of the vector. |
|
Y | The Y component of the vector. |
|
Zero | A Double2 with all of its components set to zero. |
|
Properties | ||
IsNormalized | Gets a value indicting whether this instance is normalized. |
|
Item[Int32] | Gets or sets the component at the specified index. |
|
Methods | ||
Add(Double2, Double2) | Adds two vectors. |
|
Add(ref Double2, ref Double2, out Double2) | Adds 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. |
|
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. |
|
CatmullRom(Double2, Double2, Double2, Double2, Double) | Performs a Catmull-Rom interpolation using the specified positions. |
|
CatmullRom(ref Double2, ref Double2, ref Double2, ref Double2, Double, out Double2) | Performs a Catmull-Rom interpolation using the specified positions. |
|
Clamp(Double2, Double2, Double2) | Restricts a value to be within a specified range. |
|
Clamp(ref Double2, ref Double2, ref Double2, out Double2) | Restricts a value to be within a specified range. |
|
Demodulate(Double2, Double2) | Demodulates a vector with another by performing component-wise division. |
|
Demodulate(ref Double2, ref Double2, out Double2) | Demodulates a vector with another by performing component-wise division. |
|
Distance(Double2, Double2) | Calculates the distance between two vectors. |
|
Distance(ref Double2, ref Double2, out Double) | Calculates the distance between two vectors. |
|
DistanceSquared(Double2, Double2) | Calculates the squared distance between two vectors. |
|
DistanceSquared(ref Double2, ref Double2, out Double) | Calculates the squared distance between two vectors. |
|
Divide(Double2, Double) | Scales a vector by the given value. |
|
Divide(ref Double2, Double, out Double2) | Scales a vector by the given value. |
|
Dot(Double2, Double2) | Calculates the dot product of two vectors. |
|
Dot(ref Double2, ref Double2, out Double) | Calculates the dot product of two vectors. |
|
Equals(Double2) | Determines whether the specified Double2 is equal to this instance. |
|
Equals(Object) | Determines whether the specified System.Object is equal to this instance. |
|
GetHashCode() | Returns a hash code for this instance. |
|
Hermite(Double2, Double2, Double2, Double2, Double) | Performs a Hermite spline interpolation. |
|
Hermite(ref Double2, ref Double2, ref Double2, ref Double2, Double, out Double2) | Performs a Hermite spline interpolation. |
|
Length() | Calculates the length of the vector. |
|
LengthSquared() | Calculates the squared length of the vector. |
|
Lerp(Double2, Double2, Double) | Performs a linear interpolation between two vectors. |
|
Lerp(ref Double2, ref Double2, Double, out Double2) | Performs a linear interpolation between two vectors. |
|
Max(Double2, Double2) | Returns a vector containing the largest components of the specified vectors. |
|
Max(ref Double2, ref Double2, out Double2) | Returns a vector containing the smallest components of the specified vectors. |
|
Min(Double2, Double2) | Returns a vector containing the smallest components of the specified vectors. |
|
Min(ref Double2, ref Double2, out Double2) | Returns a vector containing the smallest components of the specified vectors. |
|
Modulate(Double2, Double2) | Modulates a vector with another by performing component-wise multiplication. |
|
Modulate(ref Double2, ref Double2, out Double2) | Modulates a vector with another by performing component-wise multiplication. |
|
Multiply(Double2, Double) | Scales a vector by the given value. |
|
Multiply(ref Double2, Double, out Double2) | Scales a vector by the given value. |
|
Negate(Double2) | Reverses the direction of a given vector. |
|
Negate(ref Double2, out Double2) | Reverses the direction of a given vector. |
|
Normalize() | Converts the vector into a unit vector. |
|
Normalize(Double2) | Converts the vector into a unit vector. |
|
Normalize(ref Double2, out Double2) | Converts the vector into a unit vector. |
|
Orthogonalize(Double2[], Double2[]) | Orthogonalizes a list of vectors. |
|
Orthonormalize(Double2[], Double2[]) | Orthonormalizes a list of vectors. |
|
Reflect(Double2, Double2) | Returns the reflection of a vector off a surface that has the specified normal. |
|
Reflect(ref Double2, ref Double2, out Double2) | Returns the reflection of a vector off a surface that has the specified normal. |
|
SmoothStep(Double2, Double2, Double) | Performs a cubic interpolation between two vectors. |
|
SmoothStep(ref Double2, ref Double2, Double, out Double2) | Performs a cubic interpolation between two vectors. |
|
Subtract(Double2, Double2) | Subtracts two vectors. |
|
Subtract(ref Double2, ref Double2, out Double2) | Subtracts two vectors. |
|
ToArray() | Creates an array containing the elements of the vector. |
|
ToString() | Returns a System.String that represents this instance. |
|
ToString(IFormatProvider) | Returns a System.String that represents this instance. |
|
ToString(String) | Returns a System.String that represents this instance. |
|
ToString(String, IFormatProvider) | Returns a System.String that represents this instance. |
|
Transform(Double2, Matrix) | Transforms a 2D vector by the given Matrix. |
|
Transform(Double2, Quaternion) | Transforms a 2D vector by the given Quaternion rotation. |
|
Transform(ref Double2, ref Matrix, out Double4) | Transforms a 2D vector by the given Matrix. |
|
Transform(ref Double2, ref Quaternion, out Double2) | Transforms a 2D vector by the given Quaternion rotation. |
|
Transform(Double2[], ref Matrix, Double4[]) | Transforms an array of 2D vectors by the given Matrix. |
|
Transform(Double2[], ref Quaternion, Double2[]) | Transforms an array of vectors by the given Quaternion rotation. |
|
TransformCoordinate(Double2, Matrix) | Performs a coordinate transformation using the given Matrix. |
|
TransformCoordinate(ref Double2, ref Matrix, out Double2) | Performs a coordinate transformation using the given Matrix. |
|
TransformCoordinate(Double2[], ref Matrix, Double2[]) | Performs a coordinate transformation on an array of vectors using the given Matrix. |
|
TransformNormal(Double2, Matrix) | Performs a normal transformation using the given Matrix. |
|
TransformNormal(ref Double2, ref Matrix, out Double2) | Performs a normal transformation using the given Matrix. |
|
TransformNormal(Double2[], ref Matrix, Double2[]) | Performs a normal transformation on an array of vectors using the given Matrix. |
|
Operators | ||
Addition(Double2, Double2) | Adds two vectors. |
|
Division(Double2, Double2) | Divides a vector by the given vector, component-wise. |
|
Division(Double2, Double) | Scales a vector by the given value. |
|
Division(Double, Double2) | Divides a numerator by a vector. |
|
Equality(Double2, Double2) | Tests for equality between two objects. |
|
Explicit(Double2 to Double3) | ||
Explicit(Double2 to Double4) | ||
Explicit(Double2 to Half2) | ||
Explicit(Double2 to Vector2) | ||
Explicit(Half2 to Double2) | ||
Implicit(Vector2 to Double2) | ||
Inequality(Double2, Double2) | Tests for inequality between two objects. |
|
Multiply(Double2, Double2) | Modulates a vector with another by performing component-wise multiplication. |
|
Multiply(Double2, Double) | Scales a vector by the given value. |
|
Multiply(Double, Double2) | Scales a vector by the given value. |
|
Subtraction(Double2, Double2) | Subtracts two vectors. |
|
UnaryNegation(Double2) | Reverses the direction of a given vector. |
|
UnaryPlus(Double2) | Assert a vector (return it unchanged). |
Constructors
Double2(Vector2)
Initializes a new instance of the Double2 struct.
public Double2(Vector2 v)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | v | The Vector2 to construct the Double2 from. |
Double2(Double)
Initializes a new instance of the Double2 struct.
public Double2(double value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | value | 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
Type | Name | Description |
---|---|---|
System.Double | x | Initial value for the X component of the vector. |
System.Double | y | Initial value for the Y component of the vector. |
Double2(Double[])
Initializes a new instance of the Double2 struct.
public Double2(double[] values)
Parameters
Type | Name | Description |
---|---|---|
System.Double[] | values | The values to assign to the X and Y components of the vector. This must be an array with two elements. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
Fields
One
A Double2 with all of its components set to one.
public static readonly Double2 One
Field Value
Type | Description |
---|---|
Double2 |
SizeInBytes
The size of the Double2 type, in bytes.
public static readonly int SizeInBytes
Field Value
Type | Description |
---|---|
System.Int32 |
UnitX
The X unit Double2 (1, 0).
public static readonly Double2 UnitX
Field Value
Type | Description |
---|---|
Double2 |
UnitY
The Y unit Double2 (0, 1).
public static readonly Double2 UnitY
Field Value
Type | Description |
---|---|
Double2 |
X
The X component of the vector.
[DataMember(0)]
public double X
Field Value
Type | Description |
---|---|
System.Double |
Y
The Y component of the vector.
[DataMember(1)]
public double Y
Field Value
Type | Description |
---|---|
System.Double |
Zero
A Double2 with all of its components set to zero.
public static readonly Double2 Zero
Field Value
Type | Description |
---|---|
Double2 |
Properties
IsNormalized
Gets a value indicting whether this instance is normalized.
public readonly bool IsNormalized { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Item[Int32]
Gets or sets the component at the specified index.
public double this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the component to access. Use 0 for the X component and 1 for the Y component. |
Property Value
Type | Description |
---|---|
System.Double | The value of the X or Y component, depending on the index. |
Exceptions
Type | Condition |
---|---|
System.ArgumentOutOfRangeException | Thrown when the |
Methods
Add(Double2, Double2)
Adds two vectors.
public static Double2 Add(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to add. |
Double2 | right | The second vector to add. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to add. |
Double2 | right | The second vector to add. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value1 | A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle. |
Double2 | value2 | A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle. |
Double2 | value3 | A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle. |
System.Double | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
System.Double | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Returns
Type | Description |
---|---|
Double2 | A new Double2 containing the 2D Cartesian coordinates of the specified point. |
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
Type | Name | Description |
---|---|---|
Double2 | value1 | A Double2 containing the 2D Cartesian coordinates of vertex 1 of the triangle. |
Double2 | value2 | A Double2 containing the 2D Cartesian coordinates of vertex 2 of the triangle. |
Double2 | value3 | A Double2 containing the 2D Cartesian coordinates of vertex 3 of the triangle. |
System.Double | amount1 | Barycentric coordinate b2, which expresses the weighting factor toward vertex 2 (specified in |
System.Double | amount2 | Barycentric coordinate b3, which expresses the weighting factor toward vertex 3 (specified in |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first position in the interpolation. |
Double2 | value2 | The second position in the interpolation. |
Double2 | value3 | The third position in the interpolation. |
Double2 | value4 | The fourth position in the interpolation. |
System.Double | amount | Weighting factor. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first position in the interpolation. |
Double2 | value2 | The second position in the interpolation. |
Double2 | value3 | The third position in the interpolation. |
Double2 | value4 | The fourth position in the interpolation. |
System.Double | amount | Weighting factor. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value | The value to clamp. |
Double2 | min | The minimum value. |
Double2 | max | The maximum value. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value | The value to clamp. |
Double2 | min | The minimum value. |
Double2 | max | The maximum value. |
Double2 | result | When the method completes, contains the clamped value. |
Demodulate(Double2, Double2)
Demodulates a vector with another by performing component-wise division.
public static Double2 Demodulate(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to demodulate. |
Double2 | right | The second vector to demodulate. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to demodulate. |
Double2 | right | The second vector to demodulate. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first vector. |
Double2 | value2 | The second vector. |
Returns
Type | Description |
---|---|
System.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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first vector. |
Double2 | value2 | The second vector. |
System.Double | result | When 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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first vector. |
Double2 | value2 | The second vector. |
Returns
Type | Description |
---|---|
System.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
Type | Name | Description |
---|---|---|
Double2 | value1 | The first vector. |
Double2 | value2 | The second vector |
System.Double | result | 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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | left | First source vector. |
Double2 | right | Second source vector. |
Returns
Type | Description |
---|---|
System.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
Type | Name | Description |
---|---|---|
Double2 | left | First source vector. |
Double2 | right | Second source vector. |
System.Double | result | 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 bool Equals(Double2 other)
Parameters
Type | Name | Description |
---|---|---|
Double2 | other | The Double2 to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Equals(Object)
Determines whether the specified System.Object is equal to this instance.
public override bool Equals(object value)
Parameters
Type | Name | Description |
---|---|---|
System.Object | value | The System.Object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Overrides
GetHashCode()
Returns a hash code for this instance.
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. |
Overrides
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
Type | Name | Description |
---|---|---|
Double2 | value1 | First source position vector. |
Double2 | tangent1 | First source tangent vector. |
Double2 | value2 | Second source position vector. |
Double2 | tangent2 | Second source tangent vector. |
System.Double | amount | Weighting factor. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value1 | First source position vector. |
Double2 | tangent1 | First source tangent vector. |
Double2 | value2 | Second source position vector. |
Double2 | tangent2 | Second source tangent vector. |
System.Double | amount | Weighting factor. |
Double2 | result | When the method completes, contains the result of the Hermite spline interpolation. |
Length()
Calculates the length of the vector.
public double Length()
Returns
Type | Description |
---|---|
System.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
Type | Description |
---|---|
System.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
Type | Name | Description |
---|---|---|
Double2 | start | Start vector. |
Double2 | end | End vector. |
System.Double | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | start | Start vector. |
Double2 | end | End vector. |
System.Double | amount | Value between 0 and 1 indicating the weight of |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | left | The first source vector. |
Double2 | right | The second source vector. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first source vector. |
Double2 | right | The second source vector. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | left | The first source vector. |
Double2 | right | The second source vector. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first source vector. |
Double2 | right | The second source vector. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to modulate. |
Double2 | right | The second vector to modulate. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to modulate. |
Double2 | right | The second vector to modulate. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Double2 | result | When the method completes, contains the scaled vector. |
Negate(Double2)
Reverses the direction of a given vector.
public static Double2 Negate(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to negate. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to negate. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to normalize. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | value | The vector to normalize. |
Double2 | result | When the method completes, contains the normalized vector. |
Orthogonalize(Double2[], Double2[])
Orthogonalizes a list of vectors.
public static void Orthogonalize(Double2[] destination, params Double2[] source)
Parameters
Type | Name | Description |
---|---|---|
Double2[] | destination | The list of orthogonalized vectors. |
Double2[] | source | 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
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
Orthonormalize(Double2[], Double2[])
Orthonormalizes a list of vectors.
public static void Orthonormalize(Double2[] destination, params Double2[] source)
Parameters
Type | Name | Description |
---|---|---|
Double2[] | destination | The list of orthonormalized vectors. |
Double2[] | source | 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
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
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
Type | Name | Description |
---|---|---|
Double2 | vector | The source vector. |
Double2 | normal | Normal of the surface. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | vector | The source vector. |
Double2 | normal | Normal of the surface. |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | start | Start vector. |
Double2 | end | End vector. |
System.Double | amount | Value between 0 and 1 indicating the weight of |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | start | Start vector. |
Double2 | end | End vector. |
System.Double | amount | Value between 0 and 1 indicating the weight of |
Double2 | result | 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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to subtract. |
Double2 | right | The second vector to subtract. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to subtract. |
Double2 | right | The second vector to subtract. |
Double2 | result | When the method completes, contains the difference of the two vectors. |
ToArray()
Creates an array containing the elements of the vector.
public double[] ToArray()
Returns
Type | Description |
---|---|
System.Double[] | A two-element array containing the components of the vector. |
ToString()
Returns a System.String that represents this instance.
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Overrides
ToString(IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.IFormatProvider | formatProvider | The format provider. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String)
Returns a System.String that represents this instance.
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
ToString(String, IFormatProvider)
Returns a System.String that represents this instance.
public string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
System.String | format | The format. |
System.IFormatProvider | formatProvider | The format provider. |
Returns
Type | Description |
---|---|
System.String | A System.String that represents this instance. |
Transform(Double2, Matrix)
Transforms a 2D vector by the given Matrix.
public static Double4 Transform(Double2 vector, Matrix transform)
Parameters
Type | Name | Description |
---|---|---|
Double2 | vector | The source vector. |
Matrix | transform | The transformation Matrix. |
Returns
Type | Description |
---|---|
Double4 | The transformed Double4. |
Transform(Double2, Quaternion)
Transforms a 2D vector by the given Quaternion rotation.
public static Double2 Transform(Double2 vector, Quaternion rotation)
Parameters
Type | Name | Description |
---|---|---|
Double2 | vector | The vector to rotate. |
Quaternion | rotation | The Quaternion rotation to apply. |
Returns
Type | Description |
---|---|
Double2 | The transformed Double4. |
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
Type | Name | Description |
---|---|---|
Double2 | vector | The source vector. |
Matrix | transform | The transformation Matrix. |
Double4 | result | When 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
Type | Name | Description |
---|---|---|
Double2 | vector | The vector to rotate. |
Quaternion | rotation | The Quaternion rotation to apply. |
Double2 | result | When 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
Type | Name | Description |
---|---|---|
Double2[] | source | The array of vectors to transform. |
Matrix | transform | The transformation Matrix. |
Double4[] | destination | The array for which the transformed vectors are stored. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
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
Type | Name | Description |
---|---|---|
Double2[] | source | The array of vectors to transform. |
Quaternion | rotation | The Quaternion rotation to apply. |
Double2[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
TransformCoordinate(Double2, Matrix)
Performs a coordinate transformation using the given Matrix.
public static Double2 TransformCoordinate(Double2 coordinate, Matrix transform)
Parameters
Type | Name | Description |
---|---|---|
Double2 | coordinate | The coordinate vector to transform. |
Matrix | transform | The transformation Matrix. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | coordinate | The coordinate vector to transform. |
Matrix | transform | The transformation Matrix. |
Double2 | result | 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 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
Type | Name | Description |
---|---|---|
Double2[] | source | The array of coordinate vectors to trasnform. |
Matrix | transform | The transformation Matrix. |
Double2[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
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
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
TransformNormal(Double2, Matrix)
Performs a normal transformation using the given Matrix.
public static Double2 TransformNormal(Double2 normal, Matrix transform)
Parameters
Type | Name | Description |
---|---|---|
Double2 | normal | The normal vector to transform. |
Matrix | transform | The transformation Matrix. |
Returns
Type | Description |
---|---|
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
Type | Name | Description |
---|---|---|
Double2 | normal | The normal vector to transform. |
Matrix | transform | The transformation Matrix. |
Double2 | result | 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 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
Type | Name | Description |
---|---|---|
Double2[] | source | The array of normal vectors to transform. |
Matrix | transform | The transformation Matrix. |
Double2[] | destination | The array for which the transformed vectors are stored.
This array may be the same array as |
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
Type | Condition |
---|---|
System.ArgumentNullException | Thrown when |
System.ArgumentOutOfRangeException | Thrown when |
Operators
Addition(Double2, Double2)
Adds two vectors.
public static Double2 operator +(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to add. |
Double2 | right | The second vector to add. |
Returns
Type | Description |
---|---|
Double2 | The sum of the two vectors. |
Division(Double2, Double2)
Divides a vector by the given vector, component-wise.
public static Double2 operator /(Double2 value, Double2 by)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
Double2 | by | The by. |
Returns
Type | Description |
---|---|
Double2 | The scaled vector. |
Division(Double2, Double)
Scales a vector by the given value.
public static Double2 operator /(Double2 value, double scale)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Double2 | The scaled vector. |
Division(Double, Double2)
Divides a numerator by a vector.
public static Double2 operator /(double numerator, Double2 value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | numerator | The numerator. |
Double2 | value | The value. |
Returns
Type | Description |
---|---|
Double2 | The scaled vector. |
Equality(Double2, Double2)
Tests for equality between two objects.
public static bool operator ==(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first value to compare. |
Double2 | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Explicit(Double2 to Double3)
public static explicit operator Double3(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The value. |
Returns
Type | Description |
---|---|
Double3 | The result of the conversion. |
Explicit(Double2 to Double4)
public static explicit operator Double4(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The value. |
Returns
Type | Description |
---|---|
Double4 | The result of the conversion. |
Explicit(Double2 to Half2)
public static explicit operator Half2(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The value. |
Returns
Type | Description |
---|---|
Half2 | The result of the conversion. |
Explicit(Double2 to Vector2)
public static explicit operator Vector2(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The value. |
Returns
Type | Description |
---|---|
Vector2 | The result of the conversion. |
Explicit(Half2 to Double2)
public static explicit operator Double2(Half2 value)
Parameters
Type | Name | Description |
---|---|---|
Half2 | value | The value. |
Returns
Type | Description |
---|---|
Double2 | The result of the conversion. |
Implicit(Vector2 to Double2)
public static implicit operator Double2(Vector2 value)
Parameters
Type | Name | Description |
---|---|---|
Vector2 | value | The value. |
Returns
Type | Description |
---|---|
Double2 | The result of the conversion. |
Inequality(Double2, Double2)
Tests for inequality between two objects.
public static bool operator !=(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first value to compare. |
Double2 | right | The second value to compare. |
Returns
Type | Description |
---|---|
System.Boolean |
|
Multiply(Double2, Double2)
Modulates a vector with another by performing component-wise multiplication.
public static Double2 operator *(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to multiply. |
Double2 | right | The second vector to multiply. |
Returns
Type | Description |
---|---|
Double2 | The multiplication of the two vectors. |
Multiply(Double2, Double)
Scales a vector by the given value.
public static Double2 operator *(Double2 value, double scale)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to scale. |
System.Double | scale | The amount by which to scale the vector. |
Returns
Type | Description |
---|---|
Double2 | The scaled vector. |
Multiply(Double, Double2)
Scales a vector by the given value.
public static Double2 operator *(double scale, Double2 value)
Parameters
Type | Name | Description |
---|---|---|
System.Double | scale | The amount by which to scale the vector. |
Double2 | value | The vector to scale. |
Returns
Type | Description |
---|---|
Double2 | The scaled vector. |
Subtraction(Double2, Double2)
Subtracts two vectors.
public static Double2 operator -(Double2 left, Double2 right)
Parameters
Type | Name | Description |
---|---|---|
Double2 | left | The first vector to subtract. |
Double2 | right | The second vector to subtract. |
Returns
Type | Description |
---|---|
Double2 | The difference of the two vectors. |
UnaryNegation(Double2)
Reverses the direction of a given vector.
public static Double2 operator -(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to negate. |
Returns
Type | Description |
---|---|
Double2 | A vector facing in the opposite direction. |
UnaryPlus(Double2)
Assert a vector (return it unchanged).
public static Double2 operator +(Double2 value)
Parameters
Type | Name | Description |
---|---|---|
Double2 | value | The vector to assert (unchange). |
Returns
Type | Description |
---|---|
Double2 | The asserted (unchanged) vector. |