Struct Vector2
Represents a 2D vector using two single-precision floating-point numbers.
Implements
Inherited Members
Namespace: OpenTK.Mathematics
Assembly: OpenTK.Mathematics.dll
Syntax
[Serializable]
public struct Vector2 : IEquatable<Vector2>, IFormattable, IAdditionOperators<Vector2, Vector2, Vector2>, ISubtractionOperators<Vector2, Vector2, Vector2>, IUnaryNegationOperators<Vector2, Vector2>, IUnaryPlusOperators<Vector2, Vector2>, IMultiplyOperators<Vector2, float, Vector2>, IMultiplyOperators<Vector2, Vector2, Vector2>, IMultiplyOperators<Vector2, Matrix2, Vector2>, IMultiplyOperators<Vector2, Matrix2x3, Vector3>, IMultiplyOperators<Vector2, Matrix2x4, Vector4>, IDivisionOperators<Vector2, float, Vector2>, IDivisionOperators<Vector2, Vector2, Vector2>, IEqualityOperators<Vector2, Vector2, bool>, IAdditiveIdentity<Vector2, Vector2>, IMultiplicativeIdentity<Vector2, Vector2>, IMinMaxValue<Vector2>
Remarks
The Vector2 structure is suitable for interoperation with unmanaged code requiring two consecutive floats.
Constructors
Vector2(float)
Initializes a new instance of the Vector2 struct.
Declaration
public Vector2(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | value | The value that will initialize this instance. |
Vector2(float, float)
Initializes a new instance of the Vector2 struct.
Declaration
public Vector2(float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The x component of the Vector2. |
| float | y | The y component of the Vector2. |
Fields
NegativeInfinity
Defines an instance with all components set to negative infinity.
Declaration
public static readonly Vector2 NegativeInfinity
Field Value
| Type | Description |
|---|---|
| Vector2 |
One
Defines an instance with all components set to 1.
Declaration
public static readonly Vector2 One
Field Value
| Type | Description |
|---|---|
| Vector2 |
PositiveInfinity
Defines an instance with all components set to positive infinity.
Declaration
public static readonly Vector2 PositiveInfinity
Field Value
| Type | Description |
|---|---|
| Vector2 |
SizeInBytes
Defines the size of the Vector2 struct in bytes.
Declaration
public static readonly int SizeInBytes
Field Value
| Type | Description |
|---|---|
| int |
UnitX
Defines a unit-length Vector2 that points towards the X-axis.
Declaration
public static readonly Vector2 UnitX
Field Value
| Type | Description |
|---|---|
| Vector2 |
UnitY
Defines a unit-length Vector2 that points towards the Y-axis.
Declaration
public static readonly Vector2 UnitY
Field Value
| Type | Description |
|---|---|
| Vector2 |
X
The X component of the Vector2.
Declaration
public float X
Field Value
| Type | Description |
|---|---|
| float |
Y
The Y component of the Vector2.
Declaration
public float Y
Field Value
| Type | Description |
|---|---|
| float |
Zero
Defines an instance with all components set to 0.
Declaration
public static readonly Vector2 Zero
Field Value
| Type | Description |
|---|---|
| Vector2 |
Properties
AdditiveIdentity
Gets the additive identity of Vector2. Equivalent to Vector2.Zero.
Declaration
public static Vector2 AdditiveIdentity { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
this[int]
Gets or sets the value at the index of the Vector.
Declaration
public float this[int index] { readonly get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the component from the Vector. |
Property Value
| Type | Description |
|---|---|
| float |
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 float Length { get; }
Property Value
| Type | Description |
|---|---|
| float |
See Also
LengthFast
Gets an approximation of the vector length (magnitude).
Declaration
public readonly float LengthFast { get; }
Property Value
| Type | Description |
|---|---|
| float |
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 float LengthSquared { get; }
Property Value
| Type | Description |
|---|---|
| float |
Remarks
This property avoids the costly square root operation required by the Length property. This makes it more suitable for comparisons.
See Also
MaxValue
Gets the max value for Vector2. Equivalent to Vector2.PositiveInfinity.
Declaration
public static Vector2 MaxValue { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
MinValue
Gets the min value for Vector2. Equivalent to Vector2.NegativeInfinity.
Declaration
public static Vector2 MinValue { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
MultiplicativeIdentity
Gets the multiplicative identity of Vector2. Equivalent to Vector2.One.
Declaration
public static Vector2 MultiplicativeIdentity { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
PerpendicularLeft
Gets the perpendicular vector on the left side of this vector.
Declaration
public readonly Vector2 PerpendicularLeft { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
PerpendicularRight
Gets the perpendicular vector on the right side of this vector.
Declaration
public readonly Vector2 PerpendicularRight { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
ReciprocalLengthFast
Gets an approximation of 1 over the length (magnitude) of the vector.
Declaration
public readonly float ReciprocalLengthFast { get; }
Property Value
| Type | Description |
|---|---|
| float |
Yx
Gets or sets an OpenTK.Vector2 with the Y and X components of this instance.
Declaration
public Vector2 Yx { readonly get; set; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Methods
Abs()
Returns a new vector that is the component-wise absolute value of the vector.
Declaration
public readonly Vector2 Abs()
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise absolute value vector. |
Abs(Vector2)
Take the component-wise absolute value of a vector.
Declaration
public static Vector2 Abs(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to apply component-wise absolute value to. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise absolute value vector. |
Abs(in Vector2, out Vector2)
Take the component-wise absolute value of a vector.
Declaration
public static void Abs(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to apply component-wise absolute value to. |
| Vector2 | result | The component-wise absolute value vector. |
Add(Vector2, Vector2)
Adds two vectors.
Declaration
[Pure]
public static Vector2 Add(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Left operand. |
| Vector2 | b | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of operation. |
Add(in Vector2, in Vector2, out Vector2)
Adds two vectors.
Declaration
public static void Add(in Vector2 a, in Vector2 b, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Left operand. |
| Vector2 | b | Right operand. |
| Vector2 | result | Result of operation. |
BaryCentric(Vector2, Vector2, Vector2, float, float)
Interpolate 3 Vectors using Barycentric coordinates.
Declaration
[Pure]
public static Vector2 BaryCentric(Vector2 a, Vector2 b, Vector2 c, float u, float v)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input Vector. |
| Vector2 | b | Second input Vector. |
| Vector2 | c | Third input Vector. |
| float | u | First Barycentric Coordinate. |
| float | v | Second Barycentric Coordinate. |
Returns
| Type | Description |
|---|---|
| Vector2 | 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 Vector2, in Vector2, in Vector2, float, float, out Vector2)
Interpolate 3 Vectors using Barycentric coordinates.
Declaration
public static void BaryCentric(in Vector2 a, in Vector2 b, in Vector2 c, float u, float v, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input Vector. |
| Vector2 | b | Second input Vector. |
| Vector2 | c | Third input Vector. |
| float | u | First Barycentric Coordinate. |
| float | v | Second Barycentric Coordinate. |
| Vector2 | 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(float) on each component.
Declaration
public readonly Vector2 Ceiling()
Returns
| Type | Description |
|---|---|
| Vector2 | The ceiled vector. |
Ceiling(Vector2)
Component-wise ceiling operation. Equivalent to calling Ceiling(float) on each component.
Declaration
[Pure]
public static Vector2 Ceiling(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to take the ceiling of. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise ceiling vector. |
Ceiling(in Vector2, out Vector2)
Component-wise ceiling operation. Equivalent to calling Ceiling(float) on each component.
Declaration
public static void Ceiling(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to take the ceiling of. |
| Vector2 | result | The component-wise ceiling vector. |
Clamp(Vector2, Vector2, Vector2)
Clamp a vector to the given minimum and maximum vectors.
Declaration
[Pure]
public static Vector2 Clamp(Vector2 vec, Vector2 min, Vector2 max)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Input vector. |
| Vector2 | min | Minimum vector. |
| Vector2 | max | Maximum vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The clamped vector. |
Clamp(in Vector2, in Vector2, in Vector2, out Vector2)
Clamp a vector to the given minimum and maximum vectors.
Declaration
public static void Clamp(in Vector2 vec, in Vector2 min, in Vector2 max, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Input vector. |
| Vector2 | min | Minimum vector. |
| Vector2 | max | Maximum vector. |
| Vector2 | result | The clamped vector. |
ComponentEqual(in Vector2, in Vector2)
Component wise equal comparision of two vectors.
Declaration
public static Vector2b ComponentEqual(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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(Vector2, Vector2)
Returns a vector created from the largest of the corresponding components of the given vectors.
Declaration
[Pure]
public static Vector2 ComponentMax(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise maximum. |
ComponentMax(in Vector2, in Vector2, out Vector2)
Returns a vector created from the largest of the corresponding components of the given vectors.
Declaration
public static void ComponentMax(in Vector2 a, in Vector2 b, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
| Vector2 | result | The component-wise maximum. |
ComponentMin(Vector2, Vector2)
Returns a vector created from the smallest of the corresponding components of the given vectors.
Declaration
[Pure]
public static Vector2 ComponentMin(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise minimum. |
ComponentMin(in Vector2, in Vector2, out Vector2)
Returns a vector created from the smallest of the corresponding components of the given vectors.
Declaration
public static void ComponentMin(in Vector2 a, in Vector2 b, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
| Vector2 | result | The component-wise minimum. |
ComponentNotEqual(in Vector2, in Vector2)
Component wise not equal comparision of two vectors.
Declaration
public static Vector2b ComponentNotEqual(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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 float, out float)
Deconstructs the vector into it's individual components.
Declaration
[Pure]
public readonly void Deconstruct(out float x, out float y)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | The X component of the vector. |
| float | y | The Y component of the vector. |
Distance(Vector2, Vector2)
Compute the euclidean distance between two vectors.
Declaration
[Pure]
public static float Distance(Vector2 vec1, Vector2 vec2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec1 | The first vector. |
| Vector2 | vec2 | The second vector. |
Returns
| Type | Description |
|---|---|
| float | The distance. |
Distance(in Vector2, in Vector2, out float)
Compute the euclidean distance between two vectors.
Declaration
public static void Distance(in Vector2 vec1, in Vector2 vec2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec1 | The first vector. |
| Vector2 | vec2 | The second vector. |
| float | result | The distance. |
DistanceSquared(Vector2, Vector2)
Compute the squared euclidean distance between two vectors.
Declaration
[Pure]
public static float DistanceSquared(Vector2 vec1, Vector2 vec2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec1 | The first vector. |
| Vector2 | vec2 | The second vector. |
Returns
| Type | Description |
|---|---|
| float | The squared distance. |
DistanceSquared(in Vector2, in Vector2, out float)
Compute the squared euclidean distance between two vectors.
Declaration
public static void DistanceSquared(in Vector2 vec1, in Vector2 vec2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec1 | The first vector. |
| Vector2 | vec2 | The second vector. |
| float | result | The squared distance. |
Divide(Vector2, Vector2)
Divides a vector by the components of a vector (scale).
Declaration
[Pure]
public static Vector2 Divide(Vector2 vector, Vector2 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| Vector2 | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the operation. |
Divide(Vector2, float)
Divides a vector by a scalar.
Declaration
[Pure]
public static Vector2 Divide(Vector2 vector, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| float | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the operation. |
Divide(in Vector2, in Vector2, out Vector2)
Divide a vector by the components of a vector (scale).
Declaration
public static void Divide(in Vector2 vector, in Vector2 scale, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| Vector2 | scale | Right operand. |
| Vector2 | result | Result of the operation. |
Divide(in Vector2, float, out Vector2)
Divides a vector by a scalar.
Declaration
public static void Divide(in Vector2 vector, float scale, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| float | scale | Right operand. |
| Vector2 | result | Result of the operation. |
Dot(Vector2, Vector2)
Calculate the dot (scalar) product of two vectors.
Declaration
[Pure]
public static float Dot(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | First operand. |
| Vector2 | right | Second operand. |
Returns
| Type | Description |
|---|---|
| float | The dot product of the two inputs. |
Dot(in Vector2, in Vector2, out float)
Calculate the dot (scalar) product of two vectors.
Declaration
public static void Dot(in Vector2 left, in Vector2 right, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | First operand. |
| Vector2 | right | Second operand. |
| float | result | The dot product of the two inputs. |
Elerp(Vector2, Vector2, float)
Returns a new vector that is the exponential interpolation of the two vectors.
Equivalent to a * pow(b/a, t).
Declaration
public static Vector2 Elerp(Vector2 a, Vector2 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The starting value. Must be non-negative. |
| Vector2 | b | The end value. Must be non-negative. |
| float | t | The blend factor. |
Returns
| Type | Description |
|---|---|
| Vector2 | The exponential interpolation between |
See Also
Elerp(in Vector2, in Vector2, float, out Vector2)
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 Vector2 a, in Vector2 b, float t, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | The starting value. Must be non-negative. |
| Vector2 | b | The end value. Must be non-negative. |
| float | t | The blend factor. |
| Vector2 | result | The exponential interpolation between |
See Also
Equals(Vector2)
Indicates whether the current object is equal to another object of the same type.
Declaration
public readonly bool Equals(Vector2 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | 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 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 |
Overrides
Floor()
Returns a new vector were a component-wise floor operation has been applied. Equivalent to calling Floor(float) on each component.
Declaration
public readonly Vector2 Floor()
Returns
| Type | Description |
|---|---|
| Vector2 | The floored vector. |
Floor(Vector2)
Component-wise floor operation. Equivalent to calling Floor(float) on each component.
Declaration
[Pure]
public static Vector2 Floor(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to take the floor of. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise floored vector. |
Floor(in Vector2, out Vector2)
Component-wise floor operation. Equivalent to calling Floor(float) on each component.
Declaration
public static void Floor(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to take the floor of. |
| Vector2 | 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
GreaterThan(in Vector2, in Vector2)
Component wise greater than comparision of two vectors.
Declaration
public static Vector2b GreaterThan(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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 Vector2, in Vector2)
Component wise greater than or equal comparision of two vectors.
Declaration
public static Vector2b GreaterThanOrEqual(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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(Vector2, Vector2, Vector2)
Returns a new vector that is the component-wise linear blend of the 2 given vectors.
Declaration
[Pure]
public static Vector2 Lerp(Vector2 a, Vector2 b, Vector2 blend)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input vector. |
| Vector2 | b | Second input vector. |
| Vector2 | blend | The blend factor. |
Returns
| Type | Description |
|---|---|
| Vector2 | a when blend=0, b when blend=1, and a component-wise linear combination otherwise. |
Lerp(Vector2, Vector2, float)
Returns a new vector that is the linear blend of the 2 given vectors.
Declaration
[Pure]
public static Vector2 Lerp(Vector2 a, Vector2 b, float blend)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input vector. |
| Vector2 | b | Second input vector. |
| float | blend | The blend factor. |
Returns
| Type | Description |
|---|---|
| Vector2 | a when blend=0, b when blend=1, and a linear combination otherwise. |
Lerp(in Vector2, in Vector2, Vector2, out Vector2)
Returns a new vector that is the component-wise linear blend of the 2 given vectors.
Declaration
public static void Lerp(in Vector2 a, in Vector2 b, Vector2 blend, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input vector. |
| Vector2 | b | Second input vector. |
| Vector2 | blend | The blend factor. |
| Vector2 | result | a when blend=0, b when blend=1, and a component-wise linear combination otherwise. |
Lerp(in Vector2, in Vector2, float, out Vector2)
Returns a new vector that is the linear blend of the 2 given vectors.
Declaration
public static void Lerp(in Vector2 a, in Vector2 b, float blend, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First input vector. |
| Vector2 | b | Second input vector. |
| float | blend | The blend factor. |
| Vector2 | result | a when blend=0, b when blend=1, and a linear combination otherwise. |
LessThan(in Vector2, in Vector2)
Component wise less than comparision of two vectors.
Declaration
public static Vector2b LessThan(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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 Vector2, in Vector2)
Component wise less than or equal comparision of two vectors.
Declaration
public static Vector2b LessThanOrEqual(in Vector2 left, in Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left vector. |
| Vector2 | 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(Vector2, Vector2)
Returns the Vector2 with the maximum magnitude. If the magnitudes are equal, the first vector is selected.
Declaration
[Pure]
public static Vector2 MagnitudeMax(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | The maximum Vector2. |
MagnitudeMax(in Vector2, in Vector2, out Vector2)
Returns the Vector2 with the maximum magnitude. If the magnitudes are equal, the first vector is selected.
Declaration
public static void MagnitudeMax(in Vector2 left, in Vector2 right, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
| Vector2 | result | The magnitude-wise maximum. |
MagnitudeMin(Vector2, Vector2)
Returns the Vector2 with the minimum magnitude. If the magnitudes are equal, the second vector is selected.
Declaration
[Pure]
public static Vector2 MagnitudeMin(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | The minimum Vector2. |
MagnitudeMin(in Vector2, in Vector2, out Vector2)
Returns the Vector2 with the minimum magnitude. If the magnitudes are equal, the second vector is selected.
Declaration
public static void MagnitudeMin(in Vector2 left, in Vector2 right, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
| Vector2 | result | The magnitude-wise minimum. |
Multiply(Vector2, Vector2)
Multiplies a vector by the components a vector (scale).
Declaration
[Pure]
public static Vector2 Multiply(Vector2 vector, Vector2 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| Vector2 | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the operation. |
Multiply(Vector2, float)
Multiplies a vector by a scalar.
Declaration
[Pure]
public static Vector2 Multiply(Vector2 vector, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| float | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the operation. |
Multiply(in Vector2, in Vector2, out Vector2)
Multiplies a vector by the components of a vector (scale).
Declaration
public static void Multiply(in Vector2 vector, in Vector2 scale, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| Vector2 | scale | Right operand. |
| Vector2 | result | Result of the operation. |
Multiply(in Vector2, float, out Vector2)
Multiplies a vector by a scalar.
Declaration
public static void Multiply(in Vector2 vector, float scale, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Left operand. |
| float | scale | Right operand. |
| Vector2 | result | Result of the operation. |
Normalize()
Scales the Vector2 to unit length.
Declaration
public void Normalize()
Normalize(Vector2)
Scale a vector to unit length.
Declaration
[Pure]
public static Vector2 Normalize(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The input vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The normalized copy. |
Normalize(in Vector2, out Vector2)
Scale a vector to unit length.
Declaration
public static void Normalize(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The input vector. |
| Vector2 | result | The normalized vector. |
NormalizeFast()
Scales the Vector2 to approximately unit length.
Declaration
public void NormalizeFast()
NormalizeFast(Vector2)
Scale a vector to approximately unit length.
Declaration
[Pure]
public static Vector2 NormalizeFast(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The input vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The normalized copy. |
NormalizeFast(in Vector2, out Vector2)
Scale a vector to approximately unit length.
Declaration
public static void NormalizeFast(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The input vector. |
| Vector2 | result | The normalized vector. |
Normalized()
Returns a copy of the Vector2 scaled to unit length.
Declaration
public readonly Vector2 Normalized()
Returns
| Type | Description |
|---|---|
| Vector2 | The normalized copy. |
PerpDot(Vector2, Vector2)
Calculate the perpendicular dot (scalar) product of two vectors.
Declaration
[Pure]
public static float PerpDot(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | First operand. |
| Vector2 | right | Second operand. |
Returns
| Type | Description |
|---|---|
| float | The perpendicular dot product of the two inputs. |
PerpDot(in Vector2, in Vector2, out float)
Calculate the perpendicular dot (scalar) product of two vectors.
Declaration
public static void PerpDot(in Vector2 left, in Vector2 right, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | First operand. |
| Vector2 | right | Second operand. |
| float | 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(float) on each component.
Declaration
public readonly Vector2 Round()
Returns
| Type | Description |
|---|---|
| Vector2 | The rounded vector. |
Round(Vector2)
Component-wise rounding. Equivalent to calling Round(float) on each component.
Declaration
[Pure]
public static Vector2 Round(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to round. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise rounded vector. |
Round(Vector2, MidpointRounding)
Component-wise rounding with specified midpoint rounding rule. Equivalent to calling Round(float, MidpointRounding) on each component.
Declaration
[Pure]
public static Vector2 Round(Vector2 vec, MidpointRounding rounding)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to round. |
| MidpointRounding | rounding | The midpoint rounding rule to use. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise rounded vector. |
Round(in Vector2, out Vector2)
Component-wise rounding. Equivalent to calling Round(float) on each component.
Declaration
public static void Round(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to round. |
| Vector2 | result | The component-wise rounded vector. |
Round(in Vector2, MidpointRounding, out Vector2)
Component-wise rounding with specified midpoint rounding rule. Equivalent to calling Round(float, MidpointRounding) on each component.
Declaration
public static void Round(in Vector2 vec, MidpointRounding rounding, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to round. |
| MidpointRounding | rounding | The midpoint rounding rule to use. |
| Vector2 | 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(float, MidpointRounding) on each component.
Declaration
public readonly Vector2 Round(MidpointRounding rounding)
Parameters
| Type | Name | Description |
|---|---|---|
| MidpointRounding | rounding | The midpoint rounding rule to use. |
Returns
| Type | Description |
|---|---|
| Vector2 | The rounded vector. |
Slerp(Vector2, Vector2, float)
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 Vector2 Slerp(Vector2 a, Vector2 b, float t)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Unit vector start point. |
| Vector2 | b | Unit vector end point. |
| float | t | The blend factor. |
Returns
| Type | Description |
|---|---|
| Vector2 |
|
Slerp(in Vector2, in Vector2, float, out Vector2)
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 Vector2 a, in Vector2 b, float t, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | Unit vector start point. |
| Vector2 | b | Unit vector end point. |
| float | t | The blend factor. |
| Vector2 | result | Is |
Subtract(Vector2, Vector2)
Subtract one Vector from another.
Declaration
[Pure]
public static Vector2 Subtract(Vector2 a, Vector2 b)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the subtraction. |
Subtract(in Vector2, in Vector2, out Vector2)
Subtract one Vector from another.
Declaration
public static void Subtract(in Vector2 a, in Vector2 b, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First operand. |
| Vector2 | b | Second operand. |
| Vector2 | 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
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 ( |
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 ( |
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(Vector2, Quaternion)
Transforms a vector by a quaternion rotation.
Declaration
[Pure]
public static Vector2 Transform(Vector2 vec, Quaternion quat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Quaternion | quat | The quaternion to rotate the vector by. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the operation. |
Transform(in Vector2, in Quaternion, out Vector2)
Transforms a vector by a quaternion rotation.
Declaration
public static void Transform(in Vector2 vec, in Quaternion quat, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Quaternion | quat | The quaternion to rotate the vector by. |
| Vector2 | result | The result of the operation. |
TransformColumn(Matrix2, Vector2)
Transform a Vector by the given Matrix using right-handed notation.
Declaration
[Pure]
public static Vector2 TransformColumn(Matrix2 mat, Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
TransformColumn(in Matrix2, in Vector2, out Vector2)
Transform a Vector by the given Matrix using right-handed notation.
Declaration
public static void TransformColumn(in Matrix2 mat, in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
| Vector2 | result | The transformed vector. |
TransformFourDimensionsColumn(Matrix4x2, Vector2)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.
Declaration
[Pure]
public static Vector4 TransformFourDimensionsColumn(Matrix4x2 mat, Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4x2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
Returns
| Type | Description |
|---|---|
| Vector4 | The transformed vector in 3 dimensions. |
TransformFourDimensionsColumn(in Matrix4x2, in Vector2, out Vector4)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.
Declaration
public static void TransformFourDimensionsColumn(in Matrix4x2 mat, in Vector2 vec, out Vector4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix4x2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
| Vector4 | result | The transformed, 3-dimensional vector. |
TransformFourDimensionsRow(Vector2, Matrix2x4)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.
Declaration
[Pure]
public static Vector4 TransformFourDimensionsRow(Vector2 vec, Matrix2x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x4 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector4 | The transformed vector in 3 dimensions. |
TransformFourDimensionsRow(in Vector2, in Matrix2x4, out Vector4)
Transform a 2-dimensional vector into a 4-dimensional vector using the given 2x4 Matrix.
Declaration
public static void TransformFourDimensionsRow(in Vector2 vec, in Matrix2x4 mat, out Vector4 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x4 | mat | The desired transformation. |
| Vector4 | result | The transformed vector. |
TransformRow(Vector2, Matrix2)
Transform a Vector by the given Matrix.
Declaration
[Pure]
public static Vector2 TransformRow(Vector2 vec, Matrix2 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
TransformRow(in Vector2, in Matrix2, out Vector2)
Transform a Vector by the given Matrix.
Declaration
public static void TransformRow(in Vector2 vec, in Matrix2 mat, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2 | mat | The desired transformation. |
| Vector2 | result | The transformed vector. |
TransformThreeDimensionsColumn(Matrix3x2, Vector2)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.
Declaration
[Pure]
public static Vector3 TransformThreeDimensionsColumn(Matrix3x2 mat, Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix3x2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed vector in 3 dimensions. |
TransformThreeDimensionsColumn(in Matrix3x2, in Vector2, out Vector3)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 3x2 Matrix.
Declaration
public static void TransformThreeDimensionsColumn(in Matrix3x2 mat, in Vector2 vec, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Matrix3x2 | mat | The desired transformation. |
| Vector2 | vec | The vector to transform. |
| Vector3 | result | The transformed, 3-dimensional vector. |
TransformThreeDimensionsRow(Vector2, Matrix2x3)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.
Declaration
[Pure]
public static Vector3 TransformThreeDimensionsRow(Vector2 vec, Matrix2x3 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x3 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed vector in 3 dimensions. |
TransformThreeDimensionsRow(in Vector2, in Matrix2x3, out Vector3)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.
Declaration
public static void TransformThreeDimensionsRow(in Vector2 vec, in Matrix2x3 mat, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x3 | mat | The desired transformation. |
| Vector3 | result | The transformed, 3-dimensional vector. |
Truncate()
Returns a new vector were component-wise truncation has been applied. Equivalent to calling Truncate(float) on each component.
Declaration
public readonly Vector2 Truncate()
Returns
| Type | Description |
|---|---|
| Vector2 | The truncated vector. |
Truncate(Vector2)
Component-wise truncation. Equivalent to calling Truncate(float) on each component.
Declaration
[Pure]
public static Vector2 Truncate(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to truncate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The component-wise truncated vector. |
Truncate(in Vector2, out Vector2)
Component-wise truncation. Equivalent to calling Truncate(float) on each component.
Declaration
public static void Truncate(in Vector2 vec, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to truncate. |
| Vector2 | result | The component-wise truncated vector. |
Operators
operator +(Vector2, Vector2)
Adds the specified instances.
Declaration
[Pure]
public static Vector2 operator +(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the addition. |
operator +(Vector2, float)
Adds a scalar to an instance.
Declaration
[Pure]
public static Vector2 operator +(Vector2 left, float right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The instance. |
| float | right | The scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the operation. |
operator +(float, Vector2)
Adds a scalar to an instance.
Declaration
[Pure]
public static Vector2 operator +(float left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| float | left | The scalar. |
| Vector2 | right | The instance. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the operation. |
operator /(Vector2, Vector2)
Component-wise division between the specified instance by a scale vector.
Declaration
[Pure]
public static Vector2 operator /(Vector2 vec, Vector2 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Left operand. |
| Vector2 | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the division. |
operator /(Vector2, float)
Divides an instance by a scalar.
Declaration
[Pure]
public static Vector2 operator /(Vector2 vec, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Left operand. |
| float | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the division. |
operator /(float, Vector2)
Divides a scalar by an instance.
Declaration
[Pure]
public static Vector2 operator /(float left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| float | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the division. |
operator ==(Vector2, Vector2)
Compares the specified instances for equality.
Declaration
public static bool operator ==(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| bool | True if both instances are equal; false otherwise. |
explicit operator Vector2h(Vector2)
Converts OpenTK.Vector2 to OpenTK.Vector2h.
Declaration
[Pure]
public static explicit operator Vector2h(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to convert. |
Returns
| Type | Description |
|---|---|
| Vector2h | The resulting Vector2h. |
explicit operator Vector2i(Vector2)
Converts OpenTK.Vector2 to OpenTK.Vector2i.
Declaration
[Pure]
public static explicit operator Vector2i(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to convert. |
Returns
| Type | Description |
|---|---|
| Vector2i | The resulting Vector2i. |
explicit operator PointF(Vector2)
Declaration
[Pure]
public static explicit operator PointF(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to cast. |
Returns
| Type | Description |
|---|---|
| PointF | The resulting PointF. |
explicit operator SizeF(Vector2)
Declaration
[Pure]
public static explicit operator SizeF(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to cast. |
Returns
| Type | Description |
|---|---|
| SizeF | The resulting SizeF. |
explicit operator Vector2(Vector2)
Declaration
[Pure]
public static explicit operator Vector2(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to cast. |
Returns
| Type | Description |
|---|---|
| Vector2 |
explicit operator Vector2(Vector2)
Declaration
[Pure]
public static explicit operator Vector2(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to cast. |
Returns
| Type | Description |
|---|---|
| Vector2 |
operator >(Vector2, Vector2)
Component wise greater than comparision between the specified instances.
Declaration
[Pure]
public static Vector2b operator >(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left instance. |
| Vector2 | 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 >=(Vector2, Vector2)
Component wise greater than or equal comparision between the specified instances.
Declaration
[Pure]
public static Vector2b operator >=(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left instance. |
| Vector2 | 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(Vector2)
Converts OpenTK.Vector2 to OpenTK.Vector2d.
Declaration
[Pure]
public static implicit operator Vector2d(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The Vector2 to convert. |
Returns
| Type | Description |
|---|---|
| Vector2d | The resulting Vector2d. |
implicit operator Vector2((float X, float Y))
Initializes a new instance of the Vector2 struct using a tuple containing the component values.
Declaration
[Pure]
public static implicit operator Vector2((float X, float Y) values)
Parameters
| Type | Name | Description |
|---|---|---|
| (float X, float Y) | values | A tuple containing the component values. |
Returns
| Type | Description |
|---|---|
| Vector2 | A new instance of the Vector2 struct with the given component values. |
operator !=(Vector2, Vector2)
Compares the specified instances for inequality.
Declaration
public static bool operator !=(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| bool | True if both instances are not equal; false otherwise. |
operator <(Vector2, Vector2)
Component wise less than comparision between the specified instances.
Declaration
[Pure]
public static Vector2b operator <(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left instance. |
| Vector2 | 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 <=(Vector2, Vector2)
Component wise less than or equal comparision between the specified instances.
Declaration
[Pure]
public static Vector2b operator <=(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The left instance. |
| Vector2 | 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 *(Vector2, Matrix2)
Transform a Vector by the given Matrix.
Declaration
[Pure]
public static Vector2 operator *(Vector2 vec, Matrix2 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
operator *(Vector2, Matrix2x3)
Transform a 2-dimensional vector into a 3-dimensional vector using the given 2x3 Matrix.
Declaration
[Pure]
public static Vector3 operator *(Vector2 vec, Matrix2x3 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x3 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector3 | The transformed vector. |
operator *(Vector2, Matrix2x4)
Transform a 2-dimensional vector into a 4-dimensional vector using the given 2x4 Matrix.
Declaration
[Pure]
public static Vector4 operator *(Vector2 vec, Matrix2x4 mat)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The vector to transform. |
| Matrix2x4 | mat | The desired transformation. |
Returns
| Type | Description |
|---|---|
| Vector4 | The transformed vector. |
operator *(Vector2, Vector2)
Component-wise multiplication between the specified instance by a scale vector.
Declaration
[Pure]
public static Vector2 operator *(Vector2 vec, Vector2 scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Right operand. |
| Vector2 | scale | Left operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the multiplication. |
operator *(Vector2, float)
Multiplies the specified instance by a scalar.
Declaration
[Pure]
public static Vector2 operator *(Vector2 vec, float scale)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Left operand. |
| float | scale | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the multiplication. |
operator *(float, Vector2)
Multiplies the specified instance by a scalar.
Declaration
[Pure]
public static Vector2 operator *(float scale, Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| float | scale | Left operand. |
| Vector2 | vec | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the multiplication. |
operator -(Vector2, Vector2)
Subtracts the specified instances.
Declaration
[Pure]
public static Vector2 operator -(Vector2 left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | Left operand. |
| Vector2 | right | Right operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the subtraction. |
operator -(Vector2, float)
Subtracts an instance by a scalar.
Declaration
[Pure]
public static Vector2 operator -(Vector2 left, float right)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | left | The instance. |
| float | right | The scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the operation. |
operator -(float, Vector2)
Subtracts a scalar by an instance.
Declaration
[Pure]
public static Vector2 operator -(float left, Vector2 right)
Parameters
| Type | Name | Description |
|---|---|---|
| float | left | The scalar. |
| Vector2 | right | The instance. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the operation. |
operator -(Vector2)
Negates the specified instance.
Declaration
[Pure]
public static Vector2 operator -(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | Operand. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of negation. |
operator +(Vector2)
Computes the unary plus of the vector.
Declaration
[Pure]
public static Vector2 operator +(Vector2 vec)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vec | The instance. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the calculation. |