Struct Vector3d
Represents a 3D vector using three double-precision floating-point numbers.
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Vector3d : IEquatable<Vector3d>, IFormattable
Constructors
Vector3d(Vector2d, double)
Initializes a new instance of the Vector3d struct.
Declaration
public Vector3d(Vector2d xy, double z = 0)
Parameters
Type | Name | Description |
---|---|---|
Vector2d | xy | The x and y components of the Vector3d. |
double | z | The z component of the Vector3d. |
Vector3d(double)
Initializes a new instance of the Vector3d struct.
Declaration
public Vector3d(double value)
Parameters
Type | Name | Description |
---|---|---|
double | value | The value that will initialize this instance. |
Vector3d(double, double, double)
Initializes a new instance of the Vector3d struct.
Declaration
public Vector3d(double x, double y, double z)
Parameters
Type | Name | Description |
---|---|---|
double | x | The x component of the Vector3d. |
double | y | The y component of the Vector3d. |
double | z | The z component of the Vector3d. |
Fields
NegativeInfinity
Defines an instance with all components set to negative infinity.
Declaration
public static readonly Vector3d NegativeInfinity
Field Value
Type | Description |
---|---|
Vector3d |
One
Defines an instance with all components set to 1.
Declaration
public static readonly Vector3d One
Field Value
Type | Description |
---|---|
Vector3d |
PositiveInfinity
Defines an instance with all components set to positive infinity.
Declaration
public static readonly Vector3d PositiveInfinity
Field Value
Type | Description |
---|---|
Vector3d |
SizeInBytes
Defines the size of the Vector3d struct in bytes.
Declaration
public static readonly int SizeInBytes
Field Value
Type | Description |
---|---|
int |
UnitX
Defines a unit-length Vector3d that points towards the X-axis.
Declaration
public static readonly Vector3d UnitX
Field Value
Type | Description |
---|---|
Vector3d |
UnitY
Defines a unit-length Vector3d that points towards the Y-axis.
Declaration
public static readonly Vector3d UnitY
Field Value
Type | Description |
---|---|
Vector3d |
UnitZ
Defines a unit-length Vector3d that points towards the Z-axis.
Declaration
public static readonly Vector3d UnitZ
Field Value
Type | Description |
---|---|
Vector3d |
X
The X component of the Vector3.
Declaration
public double X
Field Value
Type | Description |
---|---|
double |
Y
The Y component of the Vector3.
Declaration
public double Y
Field Value
Type | Description |
---|---|
double |
Z
The Z component of the Vector3.
Declaration
public double Z
Field Value
Type | Description |
---|---|
double |
Zero
Defines an instance with all components set to 0.
Declaration
public static readonly Vector3d Zero
Field Value
Type | Description |
---|---|
Vector3d |
Properties
this[int]
Gets or sets the value at the index of the Vector.
Declaration
public double this[int index] { readonly get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the component from the Vector. |
Property Value
Type | Description |
---|---|
double |
Exceptions
Type | Condition |
---|---|
IndexOutOfRangeException | Thrown if the index is less than 0 or greater than 2. |
Length
Gets the length (magnitude) of the vector.
Declaration
public readonly double Length { get; }
Property Value
Type | Description |
---|---|
double |
See Also
LengthFast
Gets an approximation of the vector length (magnitude).
Declaration
public readonly double LengthFast { get; }
Property Value
Type | Description |
---|---|
double |
Remarks
This property uses an approximation of the square root function to calculate vector magnitude.
See Also
LengthSquared
Gets the square of the vector length (magnitude).
Declaration
public readonly double LengthSquared { get; }
Property Value
Type | Description |
---|---|
double |
Remarks
This property avoids the costly square root operation required by the Length property. This makes it more suitable for comparisons.
See Also
ReciprocalLengthFast
Gets an approximation of 1 over the length (magnitude) of the vector.
Declaration
public readonly double ReciprocalLengthFast { get; }
Property Value
Type | Description |
---|---|
double |
Xy
Gets or sets an OpenTK.Vector2d with the X and Y components of this instance.
Declaration
public Vector2d Xy { get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Xz
Gets or sets an OpenTK.Vector2d with the X and Z components of this instance.
Declaration
public Vector2d Xz { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Xzy
Gets or sets an OpenTK.Vector3d with the X, Z, and Y components of this instance.
Declaration
public Vector3d Xzy { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Yx
Gets or sets an OpenTK.Vector2d with the Y and X components of this instance.
Declaration
public Vector2d Yx { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Yxz
Gets or sets an OpenTK.Vector3d with the Y, X, and Z components of this instance.
Declaration
public Vector3d Yxz { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Yz
Gets or sets an OpenTK.Vector2d with the Y and Z components of this instance.
Declaration
public Vector2d Yz { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Yzx
Gets or sets an OpenTK.Vector3d with the Y, Z, and X components of this instance.
Declaration
public Vector3d Yzx { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Zx
Gets or sets an OpenTK.Vector2d with the Z and X components of this instance.
Declaration
public Vector2d Zx { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Zxy
Gets or sets an OpenTK.Vector3d with the Z, X, and Y components of this instance.
Declaration
public Vector3d Zxy { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Zy
Gets or sets an OpenTK.Vector2d with the Z and Y components of this instance.
Declaration
public Vector2d Zy { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector2d |
Zyx
Gets or sets an OpenTK.Vector3d with the Z, Y, and X components of this instance.
Declaration
public Vector3d Zyx { readonly get; set; }
Property Value
Type | Description |
---|---|
Vector3d |
Methods
Abs()
Returns a new vector that is the component-wise absolute value of the vector.
Declaration
public readonly Vector3d Abs()
Returns
Type | Description |
---|---|
Vector3d | The component-wise absolute value vector. |
Abs(Vector3d)
Take the component-wise absolute value of a vector.
Declaration
public static Vector3d Abs(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to apply component-wise absolute value to. |
Returns
Type | Description |
---|---|
Vector3d | The component-wise absolute value vector. |
Abs(in Vector3d, out Vector3d)
Take the component-wise absolute value of a vector.
Declaration
public static void Abs(in Vector3d vec, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to apply component-wise absolute value to. |
Vector3d | result | The component-wise absolute value vector. |
Add(Vector3d, Vector3d)
Adds two vectors.
Declaration
[Pure]
public static Vector3d Add(Vector3d a, Vector3d b)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | Left operand. |
Vector3d | b | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of operation. |
Add(in Vector3d, in Vector3d, out Vector3d)
Adds two vectors.
Declaration
public static void Add(in Vector3d a, in Vector3d b, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | Left operand. |
Vector3d | b | Right operand. |
Vector3d | result | Result of operation. |
BaryCentric(Vector3d, Vector3d, Vector3d, double, double)
Interpolate 3 Vectors using Barycentric coordinates.
Declaration
[Pure]
public static Vector3d BaryCentric(Vector3d a, Vector3d b, Vector3d c, double u, double v)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input Vector. |
Vector3d | b | Second input Vector. |
Vector3d | c | Third input Vector. |
double | u | First Barycentric Coordinate. |
double | v | Second Barycentric Coordinate. |
Returns
Type | Description |
---|---|
Vector3d | a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise. |
BaryCentric(in Vector3d, in Vector3d, in Vector3d, double, double, out Vector3d)
Interpolate 3 Vectors using Barycentric coordinates.
Declaration
[Pure]
public static void BaryCentric(in Vector3d a, in Vector3d b, in Vector3d c, double u, double v, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input Vector. |
Vector3d | b | Second input Vector. |
Vector3d | c | Third input Vector. |
double | u | First Barycentric Coordinate. |
double | v | Second Barycentric Coordinate. |
Vector3d | result | Output Vector. a when u=v=0, b when u=1,v=0, c when u=0,v=1, and a linear combination of a,b,c otherwise. |
CalculateAngle(Vector3d, Vector3d)
Calculates the angle (in radians) between two vectors.
Declaration
[Pure]
public static double CalculateAngle(Vector3d first, Vector3d second)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | first | The first vector. |
Vector3d | second | The second vector. |
Returns
Type | Description |
---|---|
double | Angle (in radians) between the vectors. |
Remarks
Note that the returned angle is never bigger than the constant Pi.
CalculateAngle(in Vector3d, in Vector3d, out double)
Calculates the angle (in radians) between two vectors.
Declaration
public static void CalculateAngle(in Vector3d first, in Vector3d second, out double result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | first | The first vector. |
Vector3d | second | The second vector. |
double | result | Angle (in radians) between the vectors. |
Remarks
Note that the returned angle is never bigger than the constant Pi.
Clamp(Vector3d, Vector3d, Vector3d)
Clamp a vector to the given minimum and maximum vectors.
Declaration
[Pure]
public static Vector3d Clamp(Vector3d vec, Vector3d min, Vector3d max)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | Input vector. |
Vector3d | min | Minimum vector. |
Vector3d | max | Maximum vector. |
Returns
Type | Description |
---|---|
Vector3d | The clamped vector. |
Clamp(in Vector3d, in Vector3d, in Vector3d, out Vector3d)
Clamp a vector to the given minimum and maximum vectors.
Declaration
public static void Clamp(in Vector3d vec, in Vector3d min, in Vector3d max, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | Input vector. |
Vector3d | min | Minimum vector. |
Vector3d | max | Maximum vector. |
Vector3d | result | The clamped vector. |
ComponentMax(Vector3d, Vector3d)
Returns a vector created from the largest of the corresponding components of the given vectors.
Declaration
[Pure]
public static Vector3d ComponentMax(Vector3d a, Vector3d b)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Returns
Type | Description |
---|---|
Vector3d | The component-wise maximum. |
ComponentMax(in Vector3d, in Vector3d, out Vector3d)
Returns a vector created from the largest of the corresponding components of the given vectors.
Declaration
public static void ComponentMax(in Vector3d a, in Vector3d b, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Vector3d | result | The component-wise maximum. |
ComponentMin(Vector3d, Vector3d)
Returns a vector created from the smallest of the corresponding components of the given vectors.
Declaration
[Pure]
public static Vector3d ComponentMin(Vector3d a, Vector3d b)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Returns
Type | Description |
---|---|
Vector3d | The component-wise minimum. |
ComponentMin(in Vector3d, in Vector3d, out Vector3d)
Returns a vector created from the smallest of the corresponding components of the given vectors.
Declaration
public static void ComponentMin(in Vector3d a, in Vector3d b, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Vector3d | result | The component-wise minimum. |
Cross(Vector3d, Vector3d)
Caclulate the cross (vector) product of two vectors.
Declaration
[Pure]
public static Vector3d Cross(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | First operand. |
Vector3d | right | Second operand. |
Returns
Type | Description |
---|---|
Vector3d | The cross product of the two inputs. |
Cross(in Vector3d, in Vector3d, out Vector3d)
Caclulate the cross (vector) product of two vectors.
Declaration
public static void Cross(in Vector3d left, in Vector3d right, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | First operand. |
Vector3d | right | Second operand. |
Vector3d | result | The cross product of the two inputs. |
Deconstruct(out double, out double, out double)
Deconstructs the vector into it's individual components.
Declaration
[Pure]
public readonly void Deconstruct(out double x, out double y, out double z)
Parameters
Type | Name | Description |
---|---|---|
double | x | The X component of the vector. |
double | y | The Y component of the vector. |
double | z | The Z component of the vector. |
Distance(Vector3d, Vector3d)
Compute the euclidean distance between two vectors.
Declaration
[Pure]
public static double Distance(Vector3d vec1, Vector3d vec2)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec1 | The first vector. |
Vector3d | vec2 | The second vector. |
Returns
Type | Description |
---|---|
double | The distance. |
Distance(in Vector3d, in Vector3d, out double)
Compute the euclidean distance between two vectors.
Declaration
public static void Distance(in Vector3d vec1, in Vector3d vec2, out double result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec1 | The first vector. |
Vector3d | vec2 | The second vector. |
double | result | The distance. |
DistanceSquared(Vector3d, Vector3d)
Compute the squared euclidean distance between two vectors.
Declaration
[Pure]
public static double DistanceSquared(Vector3d vec1, Vector3d vec2)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec1 | The first vector. |
Vector3d | vec2 | The second vector. |
Returns
Type | Description |
---|---|
double | The squared distance. |
DistanceSquared(in Vector3d, in Vector3d, out double)
Compute the squared euclidean distance between two vectors.
Declaration
public static void DistanceSquared(in Vector3d vec1, in Vector3d vec2, out double result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec1 | The first vector. |
Vector3d | vec2 | The second vector. |
double | result | The squared distance. |
Divide(Vector3d, Vector3d)
Divides a vector by the components of a vector (scale).
Declaration
[Pure]
public static Vector3d Divide(Vector3d vector, Vector3d scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
Vector3d | scale | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of the operation. |
Divide(Vector3d, double)
Divides a vector by a scalar.
Declaration
[Pure]
public static Vector3d Divide(Vector3d vector, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
double | scale | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of the operation. |
Divide(in Vector3d, in Vector3d, out Vector3d)
Divide a vector by the components of a vector (scale).
Declaration
public static void Divide(in Vector3d vector, in Vector3d scale, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
Vector3d | scale | Right operand. |
Vector3d | result | Result of the operation. |
Divide(in Vector3d, double, out Vector3d)
Divides a vector by a scalar.
Declaration
public static void Divide(in Vector3d vector, double scale, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
double | scale | Right operand. |
Vector3d | result | Result of the operation. |
Dot(Vector3d, Vector3d)
Calculate the dot (scalar) product of two vectors.
Declaration
[Pure]
public static double Dot(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | First operand. |
Vector3d | right | Second operand. |
Returns
Type | Description |
---|---|
double | The dot product of the two inputs. |
Dot(in Vector3d, in Vector3d, out double)
Calculate the dot (scalar) product of two vectors.
Declaration
public static void Dot(in Vector3d left, in Vector3d right, out double result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | First operand. |
Vector3d | right | Second operand. |
double | result | The dot product of the two inputs. |
Elerp(Vector3d, Vector3d, double)
Returns a new vector that is the exponential interpolation of the two vectors.
Equivalent to a * pow(b/a, t)
.
Declaration
public static Vector3d Elerp(Vector3d a, Vector3d b, double t)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | The starting value. Must be non-negative. |
Vector3d | b | The end value. Must be non-negative. |
double | t | The blend factor. |
Returns
Type | Description |
---|---|
Vector3d | The exponential interpolation between |
See Also
Elerp(in Vector3d, in Vector3d, double, out Vector3d)
Returns a new vector that is the exponential interpolation of the two vectors.
Equivalent to a * pow(b/a, t)
.
Declaration
public static void Elerp(in Vector3d a, in Vector3d b, double t, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | The starting value. Must be non-negative. |
Vector3d | b | The end value. Must be non-negative. |
double | t | The blend factor. |
Vector3d | result | The exponential interpolation between |
See Also
Equals(Vector3d)
Indicates whether the current object is equal to another object of the same type.
Declaration
public readonly bool Equals(Vector3d other)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | other | An object to compare with this object. |
Returns
Type | Description |
---|---|
bool | true if the current object is equal to the |
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current instance. |
Returns
Type | Description |
---|---|
bool | true if |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Lerp(Vector3d, Vector3d, Vector3d)
Returns a new vector that is the component-wise linear blend of the 2 given vectors.
Declaration
[Pure]
public static Vector3d Lerp(Vector3d a, Vector3d b, Vector3d blend)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input vector. |
Vector3d | b | Second input vector. |
Vector3d | blend | The blend factor. |
Returns
Type | Description |
---|---|
Vector3d | a when blend=0, b when blend=1, and a component-wise linear combination otherwise. |
Lerp(Vector3d, Vector3d, double)
Returns a new vector that is the linear blend of the 2 given vectors.
Declaration
[Pure]
public static Vector3d Lerp(Vector3d a, Vector3d b, double blend)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input vector. |
Vector3d | b | Second input vector. |
double | blend | The blend factor. |
Returns
Type | Description |
---|---|
Vector3d | a when blend=0, b when blend=1, and a linear combination otherwise. |
Lerp(in Vector3d, in Vector3d, Vector3d, out Vector3d)
Returns a new vector that is the component-wise linear blend of the 2 given vectors.
Declaration
public static void Lerp(in Vector3d a, in Vector3d b, Vector3d blend, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input vector. |
Vector3d | b | Second input vector. |
Vector3d | blend | The blend factor. |
Vector3d | result | a when blend=0, b when blend=1, and a component-wise linear combination otherwise. |
Lerp(in Vector3d, in Vector3d, double, out Vector3d)
Returns a new vector that is the linear blend of the 2 given vectors.
Declaration
public static void Lerp(in Vector3d a, in Vector3d b, double blend, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First input vector. |
Vector3d | b | Second input vector. |
double | blend | The blend factor. |
Vector3d | result | a when blend=0, b when blend=1, and a linear combination otherwise. |
MagnitudeMax(Vector3d, Vector3d)
Returns the Vector3d with the minimum magnitude.
Declaration
[Pure]
public static Vector3d MagnitudeMax(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | Left operand. |
Vector3d | right | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | The minimum Vector3d. |
MagnitudeMax(in Vector3d, in Vector3d, out Vector3d)
Returns the Vector3d with the maximum magnitude.
Declaration
public static void MagnitudeMax(in Vector3d left, in Vector3d right, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | Left operand. |
Vector3d | right | Right operand. |
Vector3d | result | The magnitude-wise maximum. |
MagnitudeMin(Vector3d, Vector3d)
Returns the Vector3d with the minimum magnitude.
Declaration
[Pure]
public static Vector3d MagnitudeMin(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | Left operand. |
Vector3d | right | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | The minimum Vector3d. |
MagnitudeMin(in Vector3d, in Vector3d, out Vector3d)
Returns the Vector3d with the minimum magnitude.
Declaration
public static void MagnitudeMin(in Vector3d left, in Vector3d right, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | Left operand. |
Vector3d | right | Right operand. |
Vector3d | result | The magnitude-wise minimum. |
Multiply(Vector3d, Vector3d)
Multiplies a vector by the components a vector (scale).
Declaration
[Pure]
public static Vector3d Multiply(Vector3d vector, Vector3d scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
Vector3d | scale | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of the operation. |
Multiply(Vector3d, double)
Multiplies a vector by a scalar.
Declaration
[Pure]
public static Vector3d Multiply(Vector3d vector, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
double | scale | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of the operation. |
Multiply(in Vector3d, in Vector3d, out Vector3d)
Multiplies a vector by the components of a vector (scale).
Declaration
public static void Multiply(in Vector3d vector, in Vector3d scale, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
Vector3d | scale | Right operand. |
Vector3d | result | Result of the operation. |
Multiply(in Vector3d, double, out Vector3d)
Multiplies a vector by a scalar.
Declaration
public static void Multiply(in Vector3d vector, double scale, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vector | Left operand. |
double | scale | Right operand. |
Vector3d | result | Result of the operation. |
Normalize()
Scales the Vector3d to unit length.
Declaration
public void Normalize()
Normalize(Vector3d)
Scale a vector to unit length.
Declaration
[Pure]
public static Vector3d Normalize(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The input vector. |
Returns
Type | Description |
---|---|
Vector3d | The normalized copy. |
Normalize(in Vector3d, out Vector3d)
Scale a vector to unit length.
Declaration
public static void Normalize(in Vector3d vec, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The input vector. |
Vector3d | result | The normalized vector. |
NormalizeFast()
Scales the Vector3d to approximately unit length.
Declaration
public void NormalizeFast()
NormalizeFast(Vector3d)
Scale a vector to approximately unit length.
Declaration
[Pure]
public static Vector3d NormalizeFast(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The input vector. |
Returns
Type | Description |
---|---|
Vector3d | The normalized copy. |
NormalizeFast(in Vector3d, out Vector3d)
Scale a vector to approximately unit length.
Declaration
public static void NormalizeFast(in Vector3d vec, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The input vector. |
Vector3d | result | The normalized vector. |
Normalized()
Returns a copy of the Vector3d scaled to unit length.
Declaration
public readonly Vector3d Normalized()
Returns
Type | Description |
---|---|
Vector3d | The normalized copy. |
Slerp(Vector3d, Vector3d, double)
Returns a new vector that is the spherical interpolation of the two given vectors.
a
and b
need to be normalized for this function to work properly.
Declaration
[Pure]
public static Vector3d Slerp(Vector3d a, Vector3d b, double t)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | Unit vector start point. |
Vector3d | b | Unit vector end point. |
double | t | The blend factor. |
Returns
Type | Description |
---|---|
Vector3d |
|
Slerp(in Vector3d, in Vector3d, double, out Vector3d)
Returns a new vector that is the spherical interpolation of the two given vectors.
a
and b
need to be normalized for this function to work properly.
Declaration
public static void Slerp(in Vector3d a, in Vector3d b, double t, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | Unit vector start point. |
Vector3d | b | Unit vector end point. |
double | t | The blend factor. |
Vector3d | result | Is |
Subtract(Vector3d, Vector3d)
Subtract one Vector from another.
Declaration
[Pure]
public static Vector3d Subtract(Vector3d a, Vector3d b)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of subtraction. |
Subtract(in Vector3d, in Vector3d, out Vector3d)
Subtract one Vector from another.
Declaration
public static void Subtract(in Vector3d a, in Vector3d b, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | a | First operand. |
Vector3d | b | Second operand. |
Vector3d | result | Result of subtraction. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The fully qualified type name. |
Overrides
ToString(IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string)
Formats the value of the current instance using the specified format.
Declaration
public string ToString(string format)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
ToString(string, IFormatProvider)
Formats the value of the current instance using the specified format.
Declaration
public readonly string ToString(string format, IFormatProvider formatProvider)
Parameters
Type | Name | Description |
---|---|---|
string | format | The format to use. -or- A null reference ( |
IFormatProvider | formatProvider | The provider to use to format the value. -or- A null reference ( |
Returns
Type | Description |
---|---|
string | The value of the current instance in the specified format. |
Transform(Vector3d, Quaterniond)
Transforms a vector by a quaternion rotation.
Declaration
[Pure]
public static Vector3d Transform(Vector3d vec, Quaterniond quat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Quaterniond | quat | The quaternion to rotate the vector by. |
Returns
Type | Description |
---|---|
Vector3d | The result of the operation. |
Transform(in Vector3d, in Quaterniond, out Vector3d)
Transforms a vector by a quaternion rotation.
Declaration
public static void Transform(in Vector3d vec, in Quaterniond quat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Quaterniond | quat | The quaternion to rotate the vector by. |
Vector3d | result | The result of the operation. |
TransformColumn(Matrix3d, Vector3d)
Transform a Vector by the given Matrix using right-handed notation.
Declaration
[Pure]
public static Vector3d TransformColumn(Matrix3d mat, Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The desired transformation. |
Vector3d | vec | The vector to transform. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
TransformColumn(in Matrix3d, in Vector3d, out Vector3d)
Transform a Vector by the given Matrix using right-handed notation.
Declaration
public static void TransformColumn(in Matrix3d mat, in Vector3d vec, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The desired transformation. |
Vector3d | vec | The vector to transform. |
Vector3d | result | The transformed vector. |
TransformNormal(Vector3d, Matrix4d)
Transform a Normal by the given Matrix.
Declaration
[Pure]
public static Vector3d TransformNormal(Vector3d norm, Matrix4d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | norm | The normal to transform. |
Matrix4d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed normal. |
Remarks
This calculates the inverse of the given matrix, use TransformNormalInverse if you already have the inverse to avoid this extra calculation.
TransformNormal(in Vector3d, in Matrix4d, out Vector3d)
Transform a Normal by the given Matrix.
Declaration
public static void TransformNormal(in Vector3d norm, in Matrix4d mat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | norm | The normal to transform. |
Matrix4d | mat | The desired transformation. |
Vector3d | result | The transformed normal. |
Remarks
This calculates the inverse of the given matrix, use TransformNormalInverse if you already have the inverse to avoid this extra calculation.
TransformNormalInverse(Vector3d, Matrix4d)
Transform a Normal by the (transpose of the) given Matrix.
Declaration
[Pure]
public static Vector3d TransformNormalInverse(Vector3d norm, Matrix4d invMat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | norm | The normal to transform. |
Matrix4d | invMat | The inverse of the desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed normal. |
Remarks
This version doesn't calculate the inverse matrix. Use this version if you already have the inverse of the desired transform to hand.
TransformNormalInverse(in Vector3d, in Matrix4d, out Vector3d)
Transform a Normal by the (transpose of the) given Matrix.
Declaration
public static void TransformNormalInverse(in Vector3d norm, in Matrix4d invMat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | norm | The normal to transform. |
Matrix4d | invMat | The inverse of the desired transformation. |
Vector3d | result | The transformed normal. |
Remarks
This version doesn't calculate the inverse matrix. Use this version if you already have the inverse of the desired transform to hand.
TransformPerspective(Vector3d, Matrix4d)
Transform a Vector3d by the given Matrix, and project the resulting Vector4 back to a Vector3.
Declaration
[Pure]
public static Vector3d TransformPerspective(Vector3d vec, Matrix4d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix4d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
TransformPerspective(in Vector3d, in Matrix4d, out Vector3d)
Transform a Vector3d by the given Matrix, and project the resulting Vector4d back to a Vector3d.
Declaration
public static void TransformPerspective(in Vector3d vec, in Matrix4d mat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix4d | mat | The desired transformation. |
Vector3d | result | The transformed vector. |
TransformPosition(Vector3d, Matrix4d)
Transform a Position by the given Matrix.
Declaration
[Pure]
public static Vector3d TransformPosition(Vector3d pos, Matrix4d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | pos | The position to transform. |
Matrix4d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed position. |
TransformPosition(in Vector3d, in Matrix4d, out Vector3d)
Transform a Position by the given Matrix.
Declaration
public static void TransformPosition(in Vector3d pos, in Matrix4d mat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | pos | The position to transform. |
Matrix4d | mat | The desired transformation. |
Vector3d | result | The transformed position. |
TransformRow(Vector3d, Matrix3d)
Transform a Vector by the given Matrix.
Declaration
[Pure]
public static Vector3d TransformRow(Vector3d vec, Matrix3d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix3d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
TransformRow(in Vector3d, in Matrix3d, out Vector3d)
Transform a Vector by the given Matrix.
Declaration
public static void TransformRow(in Vector3d vec, in Matrix3d mat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix3d | mat | The desired transformation. |
Vector3d | result | The transformed vector. |
TransformVector(Vector3d, Matrix4d)
Transform a direction vector by the given Matrix. Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
Declaration
[Pure]
public static Vector3d TransformVector(Vector3d vec, Matrix4d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix4d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
TransformVector(in Vector3d, in Matrix4d, out Vector3d)
Transform a direction vector by the given Matrix. Assumes the matrix has a bottom row of (0,0,0,1), that is the translation part is ignored.
Declaration
public static void TransformVector(in Vector3d vec, in Matrix4d mat, out Vector3d result)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix4d | mat | The desired transformation. |
Vector3d | result | The transformed vector. |
Operators
operator +(Vector3d, Vector3d)
Adds two instances.
Declaration
[Pure]
public static Vector3d operator +(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | The first instance. |
Vector3d | right | The second instance. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |
operator /(Vector3d, Vector3d)
Component-wise division between the specified instance by a scale vector.
Declaration
[Pure]
public static Vector3d operator /(Vector3d vec, Vector3d scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | Left operand. |
Vector3d | scale | Right operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of the division. |
operator /(Vector3d, double)
Divides an instance by a scalar.
Declaration
[Pure]
public static Vector3d operator /(Vector3d vec, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The instance. |
double | scale | The scalar. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |
operator ==(Vector3d, Vector3d)
Compares two instances for equality.
Declaration
public static bool operator ==(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | The first instance. |
Vector3d | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left equals right; false otherwise. |
explicit operator Vector3(Vector3d)
Converts OpenTK.Vector3d to OpenTK.Vector3.
Declaration
[Pure]
public static explicit operator Vector3(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The Vector3d to convert. |
Returns
Type | Description |
---|---|
Vector3 | The resulting Vector3. |
explicit operator Vector3h(Vector3d)
Converts OpenTK.Vector3d to OpenTK.Vector3h.
Declaration
[Pure]
public static explicit operator Vector3h(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The Vector3d to convert. |
Returns
Type | Description |
---|---|
Vector3h | The resulting Vector3h. |
explicit operator Vector3i(Vector3d)
Converts OpenTK.Vector3d to OpenTK.Vector3i.
Declaration
[Pure]
public static explicit operator Vector3i(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The Vector3d to convert. |
Returns
Type | Description |
---|---|
Vector3i | The resulting Vector3i. |
implicit operator Vector3d((double X, double Y, double Z))
Initializes a new instance of the Vector3d struct using a tuple containing the component values.
Declaration
[Pure]
public static implicit operator Vector3d((double X, double Y, double Z) values)
Parameters
Type | Name | Description |
---|---|---|
(double X, double Y, double Z) | values | A tuple containing the component values. |
Returns
Type | Description |
---|---|
Vector3d | A new instance of the Vector3d struct with the given component values. |
operator !=(Vector3d, Vector3d)
Compares two instances for inequality.
Declaration
public static bool operator !=(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | The first instance. |
Vector3d | right | The second instance. |
Returns
Type | Description |
---|---|
bool | True, if left does not equa lright; false otherwise. |
operator *(Matrix3d, Vector3d)
Transform a Vector by the given Matrix using right-handed notation.
Declaration
[Pure]
public static Vector3d operator *(Matrix3d mat, Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Matrix3d | mat | The desired transformation. |
Vector3d | vec | The vector to transform. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
operator *(Quaterniond, Vector3d)
Transforms a vector by a quaternion rotation.
Declaration
[Pure]
public static Vector3d operator *(Quaterniond quat, Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Quaterniond | quat | The quaternion to rotate the vector by. |
Vector3d | vec | The vector to transform. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
operator *(Vector3d, Matrix3d)
Transform a Vector by the given Matrix.
Declaration
[Pure]
public static Vector3d operator *(Vector3d vec, Matrix3d mat)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The vector to transform. |
Matrix3d | mat | The desired transformation. |
Returns
Type | Description |
---|---|
Vector3d | The transformed vector. |
operator *(Vector3d, Vector3d)
Component-wise multiplication between the specified instance by a scale vector.
Declaration
[Pure]
public static Vector3d operator *(Vector3d vec, Vector3d scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | Right operand. |
Vector3d | scale | Left operand. |
Returns
Type | Description |
---|---|
Vector3d | Result of multiplication. |
operator *(Vector3d, double)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Vector3d operator *(Vector3d vec, double scale)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The instance. |
double | scale | The scalar. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |
operator *(double, Vector3d)
Multiplies an instance by a scalar.
Declaration
[Pure]
public static Vector3d operator *(double scale, Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
double | scale | The scalar. |
Vector3d | vec | The instance. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |
operator -(Vector3d, Vector3d)
Subtracts two instances.
Declaration
[Pure]
public static Vector3d operator -(Vector3d left, Vector3d right)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | left | The first instance. |
Vector3d | right | The second instance. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |
operator -(Vector3d)
Negates an instance.
Declaration
[Pure]
public static Vector3d operator -(Vector3d vec)
Parameters
Type | Name | Description |
---|---|---|
Vector3d | vec | The instance. |
Returns
Type | Description |
---|---|
Vector3d | The result of the calculation. |