Show / Hide Table of Contents

Struct Vector2d

Represents a 2D vector using two double-precision floating-point numbers.

Implements
IEquatable<Vector2d>
IFormattable
IAdditionOperators<Vector2d, Vector2d, Vector2d>
ISubtractionOperators<Vector2d, Vector2d, Vector2d>
IUnaryNegationOperators<Vector2d, Vector2d>
IUnaryPlusOperators<Vector2d, Vector2d>
IMultiplyOperators<Vector2d, double, Vector2d>
IMultiplyOperators<Vector2d, Vector2d, Vector2d>
IMultiplyOperators<Vector2d, Matrix2d, Vector2d>
IMultiplyOperators<Vector2d, Matrix2x3d, Vector3d>
IMultiplyOperators<Vector2d, Matrix2x4d, Vector4d>
IDivisionOperators<Vector2d, double, Vector2d>
IDivisionOperators<Vector2d, Vector2d, Vector2d>
IEqualityOperators<Vector2d, Vector2d, bool>
IAdditiveIdentity<Vector2d, Vector2d>
IMultiplicativeIdentity<Vector2d, Vector2d>
IMinMaxValue<Vector2d>
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Vector2d : IEquatable<Vector2d>, IFormattable, IAdditionOperators<Vector2d, Vector2d, Vector2d>, ISubtractionOperators<Vector2d, Vector2d, Vector2d>, IUnaryNegationOperators<Vector2d, Vector2d>, IUnaryPlusOperators<Vector2d, Vector2d>, IMultiplyOperators<Vector2d, double, Vector2d>, IMultiplyOperators<Vector2d, Vector2d, Vector2d>, IMultiplyOperators<Vector2d, Matrix2d, Vector2d>, IMultiplyOperators<Vector2d, Matrix2x3d, Vector3d>, IMultiplyOperators<Vector2d, Matrix2x4d, Vector4d>, IDivisionOperators<Vector2d, double, Vector2d>, IDivisionOperators<Vector2d, Vector2d, Vector2d>, IEqualityOperators<Vector2d, Vector2d, bool>, IAdditiveIdentity<Vector2d, Vector2d>, IMultiplicativeIdentity<Vector2d, Vector2d>, IMinMaxValue<Vector2d>

Constructors

Vector2d(double)

Initializes a new instance of the Vector2d struct.

Declaration
public Vector2d(double value)
Parameters
Type Name Description
double value

The value that will initialize this instance.

Vector2d(double, double)

Initializes a new instance of the Vector2d struct.

Declaration
public Vector2d(double x, double y)
Parameters
Type Name Description
double x

The x component of the Vector2d.

double y

The y component of the Vector2d.

Fields

NegativeInfinity

Defines an instance with all components set to negative infinity.

Declaration
public static readonly Vector2d NegativeInfinity
Field Value
Type Description
Vector2d

One

Defines an instance with all components set to 1.

Declaration
public static readonly Vector2d One
Field Value
Type Description
Vector2d

PositiveInfinity

Defines an instance with all components set to positive infinity.

Declaration
public static readonly Vector2d PositiveInfinity
Field Value
Type Description
Vector2d

SizeInBytes

Defines the size of the Vector2d struct in bytes.

Declaration
public static readonly int SizeInBytes
Field Value
Type Description
int

UnitX

Defines a unit-length Vector2d that points towards the X-axis.

Declaration
public static readonly Vector2d UnitX
Field Value
Type Description
Vector2d

UnitY

Defines a unit-length Vector2d that points towards the Y-axis.

Declaration
public static readonly Vector2d UnitY
Field Value
Type Description
Vector2d

X

The X coordinate of this instance.

Declaration
public double X
Field Value
Type Description
double

Y

The Y coordinate of this instance.

Declaration
public double Y
Field Value
Type Description
double

Zero

Defines an instance with all components set to 0.

Declaration
public static readonly Vector2d Zero
Field Value
Type Description
Vector2d

Properties

AdditiveIdentity

Gets the additive identity of Vector2. Equivalent to Vector2.Zero.

Declaration
public static Vector2d AdditiveIdentity { get; }
Property Value
Type Description
Vector2d

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 1.

Length

Gets the length (magnitude) of the vector.

Declaration
public readonly double Length { get; }
Property Value
Type Description
double
See Also
LengthSquared

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

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.

MaxValue

Gets the max value for Vector2d. Equivalent to Vector2d.PositiveInfinity.

Declaration
public static Vector2d MaxValue { get; }
Property Value
Type Description
Vector2d

MinValue

Gets the min value for Vector2d. Equivalent to Vector2d.NegativeInfinity.

Declaration
public static Vector2d MinValue { get; }
Property Value
Type Description
Vector2d

MultiplicativeIdentity

Gets the multiplicative identity of Vector2d. Equivalent to Vector2d.One.

Declaration
public static Vector2d MultiplicativeIdentity { get; }
Property Value
Type Description
Vector2d

PerpendicularLeft

Gets the perpendicular vector on the left side of this vector.

Declaration
public readonly Vector2d PerpendicularLeft { get; }
Property Value
Type Description
Vector2d

PerpendicularRight

Gets the perpendicular vector on the right side of this vector.

Declaration
public readonly Vector2d PerpendicularRight { get; }
Property Value
Type Description
Vector2d

ReciprocalLengthFast

Gets an approximation of 1 over the length (magnitude) of the vector.

Declaration
public readonly double ReciprocalLengthFast { get; }
Property Value
Type Description
double

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

Methods

Abs()

Returns a new vector that is the component-wise absolute value of the vector.

Declaration
public readonly Vector2d Abs()
Returns
Type Description
Vector2d

The component-wise absolute value vector.

Abs(Vector2d)

Take the component-wise absolute value of a vector.

Declaration
public static Vector2d Abs(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The vector to apply component-wise absolute value to.

Returns
Type Description
Vector2d

The component-wise absolute value vector.

Abs(in Vector2d, out Vector2d)

Take the component-wise absolute value of a vector.

Declaration
public static void Abs(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to apply component-wise absolute value to.

Vector2d result

The component-wise absolute value vector.

Add(Vector2d, Vector2d)

Adds two vectors.

Declaration
[Pure]
public static Vector2d Add(Vector2d a, Vector2d b)
Parameters
Type Name Description
Vector2d a

Left operand.

Vector2d b

Right operand.

Returns
Type Description
Vector2d

Result of operation.

Add(in Vector2d, in Vector2d, out Vector2d)

Adds two vectors.

Declaration
public static void Add(in Vector2d a, in Vector2d b, out Vector2d result)
Parameters
Type Name Description
Vector2d a

Left operand.

Vector2d b

Right operand.

Vector2d result

Result of operation.

BaryCentric(Vector2d, Vector2d, Vector2d, double, double)

Interpolate 3 Vectors using Barycentric coordinates.

Declaration
[Pure]
public static Vector2d BaryCentric(Vector2d a, Vector2d b, Vector2d c, double u, double v)
Parameters
Type Name Description
Vector2d a

First input Vector.

Vector2d b

Second input Vector.

Vector2d c

Third input Vector.

double u

First Barycentric Coordinate.

double v

Second Barycentric Coordinate.

Returns
Type Description
Vector2d

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 Vector2d, in Vector2d, in Vector2d, double, double, out Vector2d)

Interpolate 3 Vectors using Barycentric coordinates.

Declaration
public static void BaryCentric(in Vector2d a, in Vector2d b, in Vector2d c, double u, double v, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First input Vector.

Vector2d b

Second input Vector.

Vector2d c

Third input Vector.

double u

First Barycentric Coordinate.

double v

Second Barycentric Coordinate.

Vector2d 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.

Ceiling()

Returns a new vector were a component-wise ceiling operation has been applied. Equivalent to calling Ceiling(double) on each component.

Declaration
public readonly Vector2d Ceiling()
Returns
Type Description
Vector2d

The ceiled vector.

Ceiling(Vector2d)

Component-wise ceiling operation. Equivalent to calling Ceiling(double) on each component.

Declaration
[Pure]
public static Vector2d Ceiling(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The vector to take the ceiling of.

Returns
Type Description
Vector2d

The component-wise ceiling vector.

Ceiling(in Vector2d, out Vector2d)

Component-wise ceiling operation. Equivalent to calling Ceiling(double) on each component.

Declaration
public static void Ceiling(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to take the ceiling of.

Vector2d result

The component-wise ceiling vector.

Clamp(Vector2d, Vector2d, Vector2d)

Clamp a vector to the given minimum and maximum vectors.

Declaration
[Pure]
public static Vector2d Clamp(Vector2d vec, Vector2d min, Vector2d max)
Parameters
Type Name Description
Vector2d vec

Input vector.

Vector2d min

Minimum vector.

Vector2d max

Maximum vector.

Returns
Type Description
Vector2d

The clamped vector.

Clamp(in Vector2d, in Vector2d, in Vector2d, out Vector2d)

Clamp a vector to the given minimum and maximum vectors.

Declaration
public static void Clamp(in Vector2d vec, in Vector2d min, in Vector2d max, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

Input vector.

Vector2d min

Minimum vector.

Vector2d max

Maximum vector.

Vector2d result

The clamped vector.

ComponentEqual(in Vector2d, in Vector2d)

Component wise equal comparision of two vectors.

Declaration
public static Vector2b ComponentEqual(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is equal to the right component.

ComponentMax(Vector2d, Vector2d)

Returns a vector created from the largest of the corresponding components of the given vectors.

Declaration
[Pure]
public static Vector2d ComponentMax(Vector2d a, Vector2d b)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Returns
Type Description
Vector2d

The component-wise maximum.

ComponentMax(in Vector2d, in Vector2d, out Vector2d)

Returns a vector created from the largest of the corresponding components of the given vectors.

Declaration
public static void ComponentMax(in Vector2d a, in Vector2d b, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Vector2d result

The component-wise maximum.

ComponentMin(Vector2d, Vector2d)

Returns a vector created from the smallest of the corresponding components of the given vectors.

Declaration
[Pure]
public static Vector2d ComponentMin(Vector2d a, Vector2d b)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Returns
Type Description
Vector2d

The component-wise minimum.

ComponentMin(in Vector2d, in Vector2d, out Vector2d)

Returns a vector created from the smallest of the corresponding components of the given vectors.

Declaration
public static void ComponentMin(in Vector2d a, in Vector2d b, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Vector2d result

The component-wise minimum.

ComponentNotEqual(in Vector2d, in Vector2d)

Component wise not equal comparision of two vectors.

Declaration
public static Vector2b ComponentNotEqual(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is not equal to the right component.

Deconstruct(out double, out double)

Deconstructs the vector into it's individual components.

Declaration
[Pure]
public readonly void Deconstruct(out double x, out double y)
Parameters
Type Name Description
double x

The X component of the vector.

double y

The Y component of the vector.

Distance(Vector2d, Vector2d)

Compute the euclidean distance between two vectors.

Declaration
[Pure]
public static double Distance(Vector2d vec1, Vector2d vec2)
Parameters
Type Name Description
Vector2d vec1

The first vector.

Vector2d vec2

The second vector.

Returns
Type Description
double

The distance.

Distance(in Vector2d, in Vector2d, out double)

Compute the euclidean distance between two vectors.

Declaration
public static void Distance(in Vector2d vec1, in Vector2d vec2, out double result)
Parameters
Type Name Description
Vector2d vec1

The first vector.

Vector2d vec2

The second vector.

double result

The distance.

DistanceSquared(Vector2d, Vector2d)

Compute the squared euclidean distance between two vectors.

Declaration
[Pure]
public static double DistanceSquared(Vector2d vec1, Vector2d vec2)
Parameters
Type Name Description
Vector2d vec1

The first vector.

Vector2d vec2

The second vector.

Returns
Type Description
double

The squared distance.

DistanceSquared(in Vector2d, in Vector2d, out double)

Compute the squared euclidean distance between two vectors.

Declaration
public static void DistanceSquared(in Vector2d vec1, in Vector2d vec2, out double result)
Parameters
Type Name Description
Vector2d vec1

The first vector.

Vector2d vec2

The second vector.

double result

The squared distance.

Divide(Vector2d, Vector2d)

Divides a vector by the components of a vector (scale).

Declaration
[Pure]
public static Vector2d Divide(Vector2d vector, Vector2d scale)
Parameters
Type Name Description
Vector2d vector

Left operand.

Vector2d scale

Right operand.

Returns
Type Description
Vector2d

Result of the operation.

Divide(Vector2d, double)

Divides a vector by a scalar.

Declaration
[Pure]
public static Vector2d Divide(Vector2d vector, double scale)
Parameters
Type Name Description
Vector2d vector

Left operand.

double scale

Right operand.

Returns
Type Description
Vector2d

Result of the operation.

Divide(in Vector2d, in Vector2d, out Vector2d)

Divide a vector by the components of a vector (scale).

Declaration
public static void Divide(in Vector2d vector, in Vector2d scale, out Vector2d result)
Parameters
Type Name Description
Vector2d vector

Left operand.

Vector2d scale

Right operand.

Vector2d result

Result of the operation.

Divide(in Vector2d, double, out Vector2d)

Divides a vector by a scalar.

Declaration
public static void Divide(in Vector2d vector, double scale, out Vector2d result)
Parameters
Type Name Description
Vector2d vector

Left operand.

double scale

Right operand.

Vector2d result

Result of the operation.

Dot(Vector2d, Vector2d)

Calculate the dot (scalar) product of two vectors.

Declaration
[Pure]
public static double Dot(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

First operand.

Vector2d right

Second operand.

Returns
Type Description
double

The dot product of the two inputs.

Dot(in Vector2d, in Vector2d, out double)

Calculate the dot (scalar) product of two vectors.

Declaration
public static void Dot(in Vector2d left, in Vector2d right, out double result)
Parameters
Type Name Description
Vector2d left

First operand.

Vector2d right

Second operand.

double result

The dot product of the two inputs.

Elerp(Vector2d, Vector2d, double)

Returns a new vector that is the exponential interpolation of the two vectors. Equivalent to a * pow(b/a, t).

Declaration
public static Vector2d Elerp(Vector2d a, Vector2d b, double t)
Parameters
Type Name Description
Vector2d a

The starting value. Must be non-negative.

Vector2d b

The end value. Must be non-negative.

double t

The blend factor.

Returns
Type Description
Vector2d

The exponential interpolation between a and b.

See Also
Elerp(double, double, double)

Elerp(in Vector2d, in Vector2d, double, out Vector2d)

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 Vector2d a, in Vector2d b, double t, out Vector2d result)
Parameters
Type Name Description
Vector2d a

The starting value. Must be non-negative.

Vector2d b

The end value. Must be non-negative.

double t

The blend factor.

Vector2d result

The exponential interpolation between a and b.

See Also
Elerp(double, double, double)

Equals(Vector2d)

Indicates whether the current object is equal to another object of the same type.

Declaration
public readonly bool Equals(Vector2d other)
Parameters
Type Name Description
Vector2d other

An object to compare with this object.

Returns
Type Description
bool

true if the current object is equal to the other parameter; otherwise, false.

Equals(object)

Indicates whether this instance and a specified object are equal.

Declaration
public override readonly bool Equals(object obj)
Parameters
Type Name Description
object obj

The object to compare with the current instance.

Returns
Type Description
bool

true if obj and this instance are the same type and represent the same value; otherwise, false.

Overrides
ValueType.Equals(object)

Floor()

Returns a new vector were a component-wise floor operation has been applied. Equivalent to calling Floor(double) on each component.

Declaration
public readonly Vector2d Floor()
Returns
Type Description
Vector2d

The floored vector.

Floor(Vector2d)

Component-wise floor operation. Equivalent to calling Floor(double) on each component.

Declaration
[Pure]
public static Vector2d Floor(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The vector to take the floor of.

Returns
Type Description
Vector2d

The component-wise floored vector.

Floor(in Vector2d, out Vector2d)

Component-wise floor operation. Equivalent to calling Floor(double) on each component.

Declaration
public static void Floor(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to take the floor of.

Vector2d result

The component-wise floored vector.

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
ValueType.GetHashCode()

GreaterThan(in Vector2d, in Vector2d)

Component wise greater than comparision of two vectors.

Declaration
public static Vector2b GreaterThan(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is greater than the right component.

GreaterThanOrEqual(in Vector2d, in Vector2d)

Component wise greater than or equal comparision of two vectors.

Declaration
public static Vector2b GreaterThanOrEqual(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is greater than or equal to the right component.

Lerp(Vector2d, Vector2d, Vector2d)

Returns a new vector that is the component-wise linear blend of the 2 given vectors.

Declaration
[Pure]
public static Vector2d Lerp(Vector2d a, Vector2d b, Vector2d blend)
Parameters
Type Name Description
Vector2d a

First input vector.

Vector2d b

Second input vector.

Vector2d blend

The blend factor.

Returns
Type Description
Vector2d

a when blend=0, b when blend=1, and a component-wise linear combination otherwise.

Lerp(Vector2d, Vector2d, double)

Returns a new vector that is the linear blend of the 2 given vectors.

Declaration
[Pure]
public static Vector2d Lerp(Vector2d a, Vector2d b, double blend)
Parameters
Type Name Description
Vector2d a

First input vector.

Vector2d b

Second input vector.

double blend

The blend factor.

Returns
Type Description
Vector2d

a when blend=0, b when blend=1, and a linear combination otherwise.

Lerp(in Vector2d, in Vector2d, Vector2d, out Vector2d)

Returns a new vector that is the component-wise linear blend of the 2 given vectors.

Declaration
public static void Lerp(in Vector2d a, in Vector2d b, Vector2d blend, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First input vector.

Vector2d b

Second input vector.

Vector2d blend

The blend factor.

Vector2d result

a when blend=0, b when blend=1, and a component-wise linear combination otherwise.

Lerp(in Vector2d, in Vector2d, double, out Vector2d)

Returns a new vector that is the linear blend of the 2 given vectors.

Declaration
public static void Lerp(in Vector2d a, in Vector2d b, double blend, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First input vector.

Vector2d b

Second input vector.

double blend

The blend factor.

Vector2d result

a when blend=0, b when blend=1, and a linear combination otherwise.

LessThan(in Vector2d, in Vector2d)

Component wise less than comparision of two vectors.

Declaration
public static Vector2b LessThan(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is less than the right component.

LessThanOrEqual(in Vector2d, in Vector2d)

Component wise less than or equal comparision of two vectors.

Declaration
public static Vector2b LessThanOrEqual(in Vector2d left, in Vector2d right)
Parameters
Type Name Description
Vector2d left

The left vector.

Vector2d right

The right vector.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is less than or equal to the right component.

MagnitudeMax(Vector2d, Vector2d)

Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the first vector is selected.

Declaration
[Pure]
public static Vector2d MagnitudeMax(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

Left operand.

Vector2d right

Right operand.

Returns
Type Description
Vector2d

The minimum Vector2d.

MagnitudeMax(in Vector2d, in Vector2d, out Vector2d)

Returns the Vector2d with the maximum magnitude. If the magnitudes are equal, the first vector is selected.

Declaration
public static void MagnitudeMax(in Vector2d left, in Vector2d right, out Vector2d result)
Parameters
Type Name Description
Vector2d left

Left operand.

Vector2d right

Right operand.

Vector2d result

The magnitude-wise maximum.

MagnitudeMin(Vector2d, Vector2d)

Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the second vector is selected.

Declaration
[Pure]
public static Vector2d MagnitudeMin(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

Left operand.

Vector2d right

Right operand.

Returns
Type Description
Vector2d

The minimum Vector2d.

MagnitudeMin(in Vector2d, in Vector2d, out Vector2d)

Returns the Vector2d with the minimum magnitude. If the magnitudes are equal, the second vector is selected.

Declaration
public static void MagnitudeMin(in Vector2d left, in Vector2d right, out Vector2d result)
Parameters
Type Name Description
Vector2d left

Left operand.

Vector2d right

Right operand.

Vector2d result

The magnitude-wise minimum.

Multiply(Vector2d, Vector2d)

Multiplies a vector by the components a vector (scale).

Declaration
[Pure]
public static Vector2d Multiply(Vector2d vector, Vector2d scale)
Parameters
Type Name Description
Vector2d vector

Left operand.

Vector2d scale

Right operand.

Returns
Type Description
Vector2d

Result of the operation.

Multiply(Vector2d, double)

Multiplies a vector by a scalar.

Declaration
[Pure]
public static Vector2d Multiply(Vector2d vector, double scale)
Parameters
Type Name Description
Vector2d vector

Left operand.

double scale

Right operand.

Returns
Type Description
Vector2d

Result of the operation.

Multiply(in Vector2d, in Vector2d, out Vector2d)

Multiplies a vector by the components of a vector (scale).

Declaration
public static void Multiply(in Vector2d vector, in Vector2d scale, out Vector2d result)
Parameters
Type Name Description
Vector2d vector

Left operand.

Vector2d scale

Right operand.

Vector2d result

Result of the operation.

Multiply(in Vector2d, double, out Vector2d)

Multiplies a vector by a scalar.

Declaration
public static void Multiply(in Vector2d vector, double scale, out Vector2d result)
Parameters
Type Name Description
Vector2d vector

Left operand.

double scale

Right operand.

Vector2d result

Result of the operation.

Normalize()

Scales the Vector2 to unit length.

Declaration
public void Normalize()

Normalize(Vector2d)

Scale a vector to unit length.

Declaration
[Pure]
public static Vector2d Normalize(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The input vector.

Returns
Type Description
Vector2d

The normalized copy.

Normalize(in Vector2d, out Vector2d)

Scale a vector to unit length.

Declaration
public static void Normalize(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The input vector.

Vector2d result

The normalized vector.

NormalizeFast()

Scales the Vector2d to approximately unit length.

Declaration
public void NormalizeFast()

NormalizeFast(Vector2d)

Scale a vector to approximately unit length.

Declaration
[Pure]
public static Vector2d NormalizeFast(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The input vector.

Returns
Type Description
Vector2d

The normalized copy.

NormalizeFast(in Vector2d, out Vector2d)

Scale a vector to approximately unit length.

Declaration
public static void NormalizeFast(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The input vector.

Vector2d result

The normalized vector.

Normalized()

Returns a copy of the Vector2d scaled to unit length.

Declaration
public readonly Vector2d Normalized()
Returns
Type Description
Vector2d

The normalized copy.

PerpDot(Vector2d, Vector2d)

Calculate the perpendicular dot (scalar) product of two vectors.

Declaration
[Pure]
public static double PerpDot(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

First operand.

Vector2d right

Second operand.

Returns
Type Description
double

The perpendicular dot product of the two inputs.

PerpDot(in Vector2d, in Vector2d, out double)

Calculate the perpendicular dot (scalar) product of two vectors.

Declaration
public static void PerpDot(in Vector2d left, in Vector2d right, out double result)
Parameters
Type Name Description
Vector2d left

First operand.

Vector2d right

Second operand.

double result

The perpendicular dot product of the two inputs.

Round()

Returns a new vector were component-wise rounding has been applied. Equivalent to calling Round(double) on each component.

Declaration
public readonly Vector2d Round()
Returns
Type Description
Vector2d

The rounded vector.

Round(Vector2d)

Component-wise rounding. Equivalent to calling Round(double) on each component.

Declaration
[Pure]
public static Vector2d Round(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The vector to round.

Returns
Type Description
Vector2d

The component-wise rounded vector.

Round(Vector2d, MidpointRounding)

Component-wise rounding with specified midpoint rounding rule. Equivalent to calling Round(double, MidpointRounding) on each component.

Declaration
[Pure]
public static Vector2d Round(Vector2d vec, MidpointRounding rounding)
Parameters
Type Name Description
Vector2d vec

The vector to round.

MidpointRounding rounding

The midpoint rounding rule to use.

Returns
Type Description
Vector2d

The component-wise rounded vector.

Round(in Vector2d, out Vector2d)

Component-wise rounding. Equivalent to calling Round(double) on each component.

Declaration
public static void Round(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to round.

Vector2d result

The component-wise rounded vector.

Round(in Vector2d, MidpointRounding, out Vector2d)

Component-wise rounding with specified midpoint rounding rule. Equivalent to calling Round(double, MidpointRounding) on each component.

Declaration
public static void Round(in Vector2d vec, MidpointRounding rounding, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to round.

MidpointRounding rounding

The midpoint rounding rule to use.

Vector2d result

The component-wise rounded vector.

Round(MidpointRounding)

Returns a new vector were component-wise rounding has been applied with the specified midpoint rounding rule. Equivalent to calling Round(double, MidpointRounding) on each component.

Declaration
public readonly Vector2d Round(MidpointRounding rounding)
Parameters
Type Name Description
MidpointRounding rounding

The midpoint rounding rule to use.

Returns
Type Description
Vector2d

The rounded vector.

Slerp(Vector2d, Vector2d, 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 Vector2d Slerp(Vector2d a, Vector2d b, double t)
Parameters
Type Name Description
Vector2d a

Unit vector start point.

Vector2d b

Unit vector end point.

double t

The blend factor.

Returns
Type Description
Vector2d

a when t=0, b when t=1, and a spherical interpolation between the vectors otherwise.

Slerp(in Vector2d, in Vector2d, double, out Vector2d)

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 Vector2d a, in Vector2d b, double t, out Vector2d result)
Parameters
Type Name Description
Vector2d a

Unit vector start point.

Vector2d b

Unit vector end point.

double t

The blend factor.

Vector2d result

Is a when t=0, b when t=1, and a spherical interpolation between the vectors otherwise.

Subtract(Vector2d, Vector2d)

Subtract one Vector from another.

Declaration
[Pure]
public static Vector2d Subtract(Vector2d a, Vector2d b)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Returns
Type Description
Vector2d

Result of the subtraction.

Subtract(in Vector2d, in Vector2d, out Vector2d)

Subtract one Vector from another.

Declaration
public static void Subtract(in Vector2d a, in Vector2d b, out Vector2d result)
Parameters
Type Name Description
Vector2d a

First operand.

Vector2d b

Second operand.

Vector2d result

Result of subtraction.

ToString()

Returns the fully qualified type name of this instance.

Declaration
public override readonly string ToString()
Returns
Type Description
string

The fully qualified type name.

Overrides
ValueType.ToString()

ToString(IFormatProvider)

Formats the value of the current instance using the specified format.

Declaration
public readonly string ToString(IFormatProvider formatProvider)
Parameters
Type Name Description
IFormatProvider formatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

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 readonly string ToString(string format)
Parameters
Type Name Description
string format

The format to use.

-or-

A null reference (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

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 (Nothing in Visual Basic) to use the default format defined for the type of the IFormattable implementation.

IFormatProvider formatProvider

The provider to use to format the value.

-or-

A null reference (Nothing in Visual Basic) to obtain the numeric format information from the current locale setting of the operating system.

Returns
Type Description
string

The value of the current instance in the specified format.

Transform(Vector2d, Quaterniond)

Transforms a vector by a quaternion rotation.

Declaration
[Pure]
public static Vector2d Transform(Vector2d vec, Quaterniond quat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Quaterniond quat

The quaternion to rotate the vector by.

Returns
Type Description
Vector2d

The result of the operation.

Transform(in Vector2d, in Quaterniond, out Vector2d)

Transforms a vector by a quaternion rotation.

Declaration
public static void Transform(in Vector2d vec, in Quaterniond quat, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Quaterniond quat

The quaternion to rotate the vector by.

Vector2d result

The result of the operation.

TransformColumn(Matrix2d, Vector2d)

Transform a Vector by the given Matrix using right-handed notation.

Declaration
[Pure]
public static Vector2d TransformColumn(Matrix2d mat, Vector2d vec)
Parameters
Type Name Description
Matrix2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Returns
Type Description
Vector2d

The transformed vector.

TransformColumn(in Matrix2d, in Vector2d, out Vector2d)

Transform a Vector by the given Matrix using right-handed notation.

Declaration
public static void TransformColumn(in Matrix2d mat, in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Matrix2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Vector2d result

The transformed vector.

TransformFourDimensionsColumn(Matrix4x2d, Vector2d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.

Declaration
[Pure]
public static Vector4d TransformFourDimensionsColumn(Matrix4x2d mat, Vector2d vec)
Parameters
Type Name Description
Matrix4x2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Returns
Type Description
Vector4d

The transformed vector in 3 dimensions.

TransformFourDimensionsColumn(in Matrix4x2d, in Vector2d, out Vector4d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.

Declaration
public static void TransformFourDimensionsColumn(in Matrix4x2d mat, in Vector2d vec, out Vector4d result)
Parameters
Type Name Description
Matrix4x2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Vector4d result

The transformed, 3-dimensional vector.

TransformFourDimensionsRow(Vector2d, Matrix2x4d)

Transform a 2-dimensional vector into a 4-dimensional vector using the given 2x4 Matrix.

Declaration
[Pure]
public static Vector4d TransformFourDimensionsRow(Vector2d vec, Matrix2x4d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x4d mat

The desired transformation.

Returns
Type Description
Vector4d

The transformed vector in 4 dimensions.

TransformFourDimensionsRow(in Vector2d, in Matrix2x4d, out Vector4d)

Transform a 2-dimensional vector into a 4-dimensional vector using the given 2x4 Matrix.

Declaration
public static void TransformFourDimensionsRow(in Vector2d vec, in Matrix2x4d mat, out Vector4d result)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x4d mat

The desired transformation.

Vector4d result

The transformed, 4-dimensional vector.

TransformRow(Vector2d, Matrix2d)

Transform a Vector by the given Matrix.

Declaration
[Pure]
public static Vector2d TransformRow(Vector2d vec, Matrix2d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2d mat

The desired transformation.

Returns
Type Description
Vector2d

The transformed vector.

TransformRow(in Vector2d, in Matrix2d, out Vector2d)

Transform a Vector by the given Matrix.

Declaration
public static void TransformRow(in Vector2d vec, in Matrix2d mat, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2d mat

The desired transformation.

Vector2d result

The transformed vector.

TransformThreeDimensionsColumn(Matrix3x2d, Vector2d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.

Declaration
[Pure]
public static Vector3d TransformThreeDimensionsColumn(Matrix3x2d mat, Vector2d vec)
Parameters
Type Name Description
Matrix3x2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Returns
Type Description
Vector3d

The transformed vector in 3 dimensions.

TransformThreeDimensionsColumn(in Matrix3x2d, in Vector2d, out Vector3d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.

Declaration
public static void TransformThreeDimensionsColumn(in Matrix3x2d mat, in Vector2d vec, out Vector3d result)
Parameters
Type Name Description
Matrix3x2d mat

The desired transformation.

Vector2d vec

The vector to transform.

Vector3d result

The transformed, 3-dimensional vector.

TransformThreeDimensionsRow(Vector2d, Matrix2x3d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.

Declaration
[Pure]
public static Vector3d TransformThreeDimensionsRow(Vector2d vec, Matrix2x3d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x3d mat

The desired transformation.

Returns
Type Description
Vector3d

The transformed vector in 3 dimensions.

TransformThreeDimensionsRow(in Vector2d, in Matrix2x3d, out Vector3d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.

Declaration
public static void TransformThreeDimensionsRow(in Vector2d vec, in Matrix2x3d mat, out Vector3d result)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x3d mat

The desired transformation.

Vector3d result

The transformed, 3-dimensional vector.

Truncate()

Returns a new vector were component-wise truncation has been applied. Equivalent to calling Truncate(double) on each component.

Declaration
public readonly Vector2d Truncate()
Returns
Type Description
Vector2d

The truncated vector.

Truncate(Vector2d)

Component-wise truncation. Equivalent to calling Truncate(double) on each component.

Declaration
[Pure]
public static Vector2d Truncate(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The vector to truncate.

Returns
Type Description
Vector2d

The component-wise truncated vector.

Truncate(in Vector2d, out Vector2d)

Component-wise truncation. Equivalent to calling Truncate(double) on each component.

Declaration
public static void Truncate(in Vector2d vec, out Vector2d result)
Parameters
Type Name Description
Vector2d vec

The vector to truncate.

Vector2d result

The component-wise truncated vector.

Operators

operator +(Vector2d, Vector2d)

Adds two instances.

Declaration
[Pure]
public static Vector2d operator +(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2d

The result of the operation.

operator +(Vector2d, double)

Adds a scalar to an instance.

Declaration
[Pure]
public static Vector2d operator +(Vector2d left, double right)
Parameters
Type Name Description
Vector2d left

The instance.

double right

The scalar.

Returns
Type Description
Vector2d

The result of the operation.

operator +(double, Vector2d)

Adds a scalar to an instance.

Declaration
[Pure]
public static Vector2d operator +(double left, Vector2d right)
Parameters
Type Name Description
double left

The scalar.

Vector2d right

The instance.

Returns
Type Description
Vector2d

The result of the operation.

operator /(Vector2d, Vector2d)

Divides an instance by a scalar.

Declaration
[Pure]
public static Vector2d operator /(Vector2d vec, Vector2d scale)
Parameters
Type Name Description
Vector2d vec

Left operand.

Vector2d scale

Right operand.

Returns
Type Description
Vector2d

Result of the division.

operator /(Vector2d, double)

Divides an instance by a scalar.

Declaration
[Pure]
public static Vector2d operator /(Vector2d vec, double scale)
Parameters
Type Name Description
Vector2d vec

The instance.

double scale

The scalar.

Returns
Type Description
Vector2d

Result of the division.

operator /(double, Vector2d)

Divides a scalar by an instance.

Declaration
[Pure]
public static Vector2d operator /(double left, Vector2d right)
Parameters
Type Name Description
double left

The scalar.

Vector2d right

The instance.

Returns
Type Description
Vector2d

Result of the division.

operator ==(Vector2d, Vector2d)

Compares two instances for equality.

Declaration
public static bool operator ==(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
bool

True, if both instances are equal; false otherwise.

explicit operator Vector2(Vector2d)

Converts OpenTK.Vector2d to OpenTK.Vector2.

Declaration
[Pure]
public static explicit operator Vector2(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The Vector2d to convert.

Returns
Type Description
Vector2

The resulting Vector2.

explicit operator Vector2h(Vector2d)

Converts OpenTK.Vector2d to OpenTK.Vector2h.

Declaration
[Pure]
public static explicit operator Vector2h(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The Vector2d to convert.

Returns
Type Description
Vector2h

The resulting Vector2h.

explicit operator Vector2i(Vector2d)

Converts OpenTK.Vector2d to OpenTK.Vector2i.

Declaration
[Pure]
public static explicit operator Vector2i(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The Vector2d to convert.

Returns
Type Description
Vector2i

The resulting Vector2i.

operator >(Vector2d, Vector2d)

Component wise greater than comparision between the specified instances.

Declaration
[Pure]
public static Vector2b operator >(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding greater component is greater than the right component.

operator >=(Vector2d, Vector2d)

Component wise greater than or equal comparision between the specified instances.

Declaration
[Pure]
public static Vector2b operator >=(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is greater than or equal the right component.

implicit operator Vector2d((double X, double Y))

Initializes a new instance of the Vector2d struct using a tuple containing the component values.

Declaration
[Pure]
public static implicit operator Vector2d((double X, double Y) values)
Parameters
Type Name Description
(double X, double Y) values

A tuple containing the component values.

Returns
Type Description
Vector2d

A new instance of the Vector2d struct with the given component values.

operator !=(Vector2d, Vector2d)

Compares two instances for ienquality.

Declaration
public static bool operator !=(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
bool

True, if the instances are not equal; false otherwise.

operator <(Vector2d, Vector2d)

Component wise less than comparision between the specified instances.

Declaration
[Pure]
public static Vector2b operator <(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is less than the right component.

operator <=(Vector2d, Vector2d)

Component wise less than or equal comparision between the specified instances.

Declaration
[Pure]
public static Vector2b operator <=(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2b

A component wise boolean vector whose compoennts are true when the corresponding left component is less than or equal the right component.

operator *(Vector2d, Matrix2d)

Transform a Vector by the given Matrix.

Declaration
[Pure]
public static Vector2d operator *(Vector2d vec, Matrix2d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2d mat

The desired transformation.

Returns
Type Description
Vector2d

The transformed vector.

operator *(Vector2d, Matrix2x3d)

Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.

Declaration
[Pure]
public static Vector3d operator *(Vector2d vec, Matrix2x3d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x3d mat

The desired transformation.

Returns
Type Description
Vector3d

The transformed vector.

operator *(Vector2d, Matrix2x4d)

Transform a 2-dimensional vector into a 4-dimensional vector using the given 2x4 Matrix.

Declaration
[Pure]
public static Vector4d operator *(Vector2d vec, Matrix2x4d mat)
Parameters
Type Name Description
Vector2d vec

The vector to transform.

Matrix2x4d mat

The desired transformation.

Returns
Type Description
Vector4d

The transformed vector.

operator *(Vector2d, Vector2d)

Component-wise multiplication between the specified instance by a scale vector.

Declaration
[Pure]
public static Vector2d operator *(Vector2d vec, Vector2d scale)
Parameters
Type Name Description
Vector2d vec

Right operand.

Vector2d scale

Left operand.

Returns
Type Description
Vector2d

Result of the multiplication.

operator *(Vector2d, double)

Multiplies an instance by a scalar.

Declaration
[Pure]
public static Vector2d operator *(Vector2d vec, double scale)
Parameters
Type Name Description
Vector2d vec

The instance.

double scale

The scalar.

Returns
Type Description
Vector2d

The result of the operation.

operator *(double, Vector2d)

Multiply an instance by a scalar.

Declaration
[Pure]
public static Vector2d operator *(double scale, Vector2d vec)
Parameters
Type Name Description
double scale

The scalar.

Vector2d vec

The instance.

Returns
Type Description
Vector2d

The result of the operation.

operator -(Vector2d, Vector2d)

Subtracts two instances.

Declaration
[Pure]
public static Vector2d operator -(Vector2d left, Vector2d right)
Parameters
Type Name Description
Vector2d left

The left instance.

Vector2d right

The right instance.

Returns
Type Description
Vector2d

The result of the operation.

operator -(Vector2d, double)

Subtracts an instance by a scalar.

Declaration
[Pure]
public static Vector2d operator -(Vector2d left, double right)
Parameters
Type Name Description
Vector2d left

The instance.

double right

The scalar.

Returns
Type Description
Vector2d

The result of the operation.

operator -(double, Vector2d)

Subtracts a scalar by an instance.

Declaration
[Pure]
public static Vector2d operator -(double left, Vector2d right)
Parameters
Type Name Description
double left

The scalar.

Vector2d right

The instance.

Returns
Type Description
Vector2d

The result of the operation.

operator -(Vector2d)

Negates an instance.

Declaration
[Pure]
public static Vector2d operator -(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The instance.

Returns
Type Description
Vector2d

The result of the operation.

operator +(Vector2d)

Computes the unary plus of the vector.

Declaration
[Pure]
public static Vector2d operator +(Vector2d vec)
Parameters
Type Name Description
Vector2d vec

The instance.

Returns
Type Description
Vector2d

The result of the calculation.

Implements

IEquatable<T>
IFormattable
IAdditionOperators<TSelf, TOther, TResult>
ISubtractionOperators<TSelf, TOther, TResult>
IUnaryNegationOperators<TSelf, TResult>
IUnaryPlusOperators<TSelf, TResult>
IMultiplyOperators<TSelf, TOther, TResult>
IMultiplyOperators<TSelf, TOther, TResult>
IMultiplyOperators<TSelf, TOther, TResult>
IMultiplyOperators<TSelf, TOther, TResult>
IMultiplyOperators<TSelf, TOther, TResult>
IDivisionOperators<TSelf, TOther, TResult>
IDivisionOperators<TSelf, TOther, TResult>
IEqualityOperators<TSelf, TOther, TResult>
IAdditiveIdentity<TSelf, TResult>
IMultiplicativeIdentity<TSelf, TResult>
IMinMaxValue<TSelf>
In this article
Back to top Generated by DocFX