Struct Vector2
Represents a vector in a 2D coordinate system.
Namespace: Evergine.Mathematics
Assembly: Evergine.Mathematics.dll
Syntax
public struct Vector2
Constructors
Vector2(float)
Initializes a new instance of the Vector2 struct.
Declaration
public Vector2(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | value | The x and y coordinates in 2D space. |
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-coordinate in 2D space. |
| float | y | The y-coordinate in 2D space. |
Fields
X
The x-coordinate of this Vector2.
Declaration
public float X
Field Value
| Type | Description |
|---|---|
| float |
Y
The y-coordinate of this Vector2.
Declaration
public float Y
Field Value
| Type | Description |
|---|---|
| float |
Properties
Center
Gets a Vector2 with components 0.5f, 0.5f.
Declaration
public static Vector2 Center { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Down
Gets a Vector2 with components (0, 1).
Declaration
public static Vector2 Down { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
this[int]
Gets or sets the component at the specified index.
Declaration
public float this[int index] { get; set; }
Parameters
| Type | Name | Description |
|---|---|---|
| int | index | The index of the component to access. Use 0 for the X component and 1 for the Y component. |
Property Value
| Type | Description |
|---|---|
| float | The value of the X or Y component, depending on the index. |
Left
Gets a Vector2 with components -1 and 0.
Declaration
public static Vector2 Left { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
One
Gets a Vector2 with components 1, 1.
Declaration
public static Vector2 One { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Right
Gets a Vector2 with components 1, 0.
Declaration
public static Vector2 Right { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
UnitX
Gets a Vector2 with components 1 and 0.
Declaration
public static Vector2 UnitX { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
UnitY
Gets a Vector2 with components (0, 1).
Declaration
public static Vector2 UnitY { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Up
Gets a Vector2 with components 0, -1.
Declaration
public static Vector2 Up { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Zero
Gets a Vector2 with components 0, 0.
Declaration
public static Vector2 Zero { get; }
Property Value
| Type | Description |
|---|---|
| Vector2 |
Methods
Abs(Vector2)
Creates a new Vector2 that contains the absolute values from a vector.
Declaration
public static Vector2 Abs(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The Vector2 with absolute values from a vector. |
Abs(ref Vector2, out Vector2)
Creates a new Vector2 that contains the absolute values from a vector.
Declaration
public static void Abs(ref Vector2 value, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The vector. |
| Vector2 | result | The Vector2 with absolute values from the vector as an output parameter. |
Add(Vector2, Vector2)
Performs vector addition on value1 and value2.
Declaration
public static Vector2 Add(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to add. |
| Vector2 | value2 | The second vector to add. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the vector addition. |
Add(ref Vector2, ref Vector2, out Vector2)
Performs vector addition on value1 and value2, storing the result of
the addition in result.
Declaration
public static void Add(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to add. |
| Vector2 | value2 | The second vector to add. |
| Vector2 | result | The result of the vector addition as an output parameter. |
Angle(Vector2, Vector2)
Returns the angle in radians between two vectors.
Declaration
public static float Angle(Vector2 from, Vector2 to)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | from | From vector. |
| Vector2 | to | To vector. |
Returns
| Type | Description |
|---|---|
| float | The angle in radians between two vectors. |
Angle(ref Vector2, ref Vector2)
Returns the angle in radians between two vectors.
Declaration
public static float Angle(ref Vector2 from, ref Vector2 to)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | from | From vector. |
| Vector2 | to | To vector. |
Returns
| Type | Description |
|---|---|
| float | The angle in radians between two vectors. |
Barycentric(Vector2, Vector2, Vector2, float, float)
Creates a new Vector2 that contains the Cartesian coordinates of a vector specified in barycentric coordinates relative to a 2D triangle.
Declaration
public static Vector2 Barycentric(Vector2 value1, Vector2 value2, Vector2 value3, float amount1, float amount2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector of the 2D triangle. |
| Vector2 | value2 | The second vector of the 2D triangle. |
| Vector2 | value3 | The third vector of the 2D triangle. |
| float | amount1 | Barycentric scalar |
| float | amount2 | Barycentric scalar |
Returns
| Type | Description |
|---|---|
| Vector2 | The Cartesian translation of barycentric coordinates. |
Barycentric(ref Vector2, ref Vector2, ref Vector2, float, float, out Vector2)
Creates a new Vector2 that contains the Cartesian coordinates of a vector specified in barycentric coordinates and relative to a 2D triangle.
Declaration
public static void Barycentric(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, float amount1, float amount2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector of the 2D triangle. |
| Vector2 | value2 | The second vector of the 2D triangle. |
| Vector2 | value3 | The third vector of the 2D triangle. |
| float | amount1 | Barycentric scalar |
| float | amount2 | Barycentric scalar |
| Vector2 | result | The Cartesian translation of barycentric coordinates as an output parameter. |
CatmullRom(Vector2, Vector2, Vector2, Vector2, float)
Creates a new Vector2 that contains CatmullRom interpolation of the specified vectors.
Declaration
public static Vector2 CatmullRom(Vector2 value1, Vector2 value2, Vector2 value3, Vector2 value4, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector in the interpolation. |
| Vector2 | value2 | The second vector in the interpolation. |
| Vector2 | value3 | The third vector in the interpolation. |
| Vector2 | value4 | The fourth vector in the interpolation. |
| float | amount | Weighting factor. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of CatmullRom interpolation. |
CatmullRom(ref Vector2, ref Vector2, ref Vector2, ref Vector2, float, out Vector2)
Creates a new Vector2 that contains CatmullRom interpolation of the specified vectors.
Declaration
public static void CatmullRom(ref Vector2 value1, ref Vector2 value2, ref Vector2 value3, ref Vector2 value4, float amount, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector in the interpolation. |
| Vector2 | value2 | The second vector in the interpolation. |
| Vector2 | value3 | The third vector in the interpolation. |
| Vector2 | value4 | The fourth vector in the interpolation. |
| float | amount | Weighting factor. |
| Vector2 | result | The result of the CatmullRom interpolation as an output parameter. |
Clamp(Vector2, Vector2, Vector2)
Clamps the specified value within a range.
Declaration
public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The value to clamp. |
| Vector2 | min | The minimum value. |
| Vector2 | max | The maximum value. |
Returns
| Type | Description |
|---|---|
| Vector2 | The clamped value. |
Clamp(ref Vector2, ref Vector2, ref Vector2, out Vector2)
Clamps the specified value within a range.
Declaration
public static void Clamp(ref Vector2 value1, ref Vector2 min, ref Vector2 max, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The value to clamp. |
| Vector2 | min | The minimum value. |
| Vector2 | max | The maximum value. |
| Vector2 | result | The clamped value as an output parameter. |
ClampMagnitude(Vector2, float)
Returns a vector with its magnitude clamped to maxLength.
Declaration
public static Vector2 ClampMagnitude(Vector2 vector, float maxLength)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | The vector. |
| float | maxLength | The maximum length. |
Returns
| Type | Description |
|---|---|
| Vector2 | The clamped vector. |
Collinear(ref Vector2, ref Vector2, ref Vector2)
Determines if three vertices are collinear (i.e., on a straight line).
Declaration
public static bool Collinear(ref Vector2 a, ref Vector2 b, ref Vector2 c)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First vertex. |
| Vector2 | b | Second vertex. |
| Vector2 | c | Third vertex. |
Returns
| Type | Description |
|---|---|
| bool |
|
Collinear(ref Vector2, ref Vector2, ref Vector2, float)
Determines if three vertices are collinear (i.e., on a straight line).
Declaration
public static bool Collinear(ref Vector2 a, ref Vector2 b, ref Vector2 c, float tolerance)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | a | First vertex. |
| Vector2 | b | Second vertex. |
| Vector2 | c | Third vertex. |
| float | tolerance | A non-negative tolerance that is used to determine the collinearity of the vertices. |
Returns
| Type | Description |
|---|---|
| bool |
|
Distance(Vector2, Vector2)
Returns the distance between two vectors.
Declaration
public static float Distance(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| float | The distance between the two vectors. |
Distance(ref Vector2, ref Vector2, out float)
Returns the distance between two vectors.
Declaration
public static void Distance(ref Vector2 value1, ref Vector2 value2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | result | The distance between the two vectors as an output parameter. |
DistanceSquared(Vector2, Vector2)
Returns the squared distance between two vectors.
Declaration
public static float DistanceSquared(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| float | The squared distance between the two vectors. |
DistanceSquared(ref Vector2, ref Vector2, out float)
Returns the squared distance between two vectors.
Declaration
public static void DistanceSquared(ref Vector2 value1, ref Vector2 value2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | result | The squared distance between the two vectors as an output parameter. |
Divide(Vector2, Vector2)
Declaration
public static Vector2 Divide(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| Vector2 | value2 | Divisor Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of dividing the vectors. |
Divide(Vector2, float)
Divides the components of a Vector2 by a scalar.
Declaration
public static Vector2 Divide(Vector2 value1, float divider)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| float | divider | Divisor scalar. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of dividing the vector by a scalar. |
Divide(ref Vector2, ref Vector2, out Vector2)
Declaration
public static void Divide(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| Vector2 | value2 | Divisor Vector2. |
| Vector2 | result | The result of dividing the vectors returned as an output parameter. |
Divide(ref Vector2, float, out Vector2)
Divides the components of a Vector2 by a scalar.
Declaration
public static void Divide(ref Vector2 value1, float divider, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| float | divider | Divisor scalar. |
| Vector2 | result | The result of dividing a vector by a scalar, provided as an output parameter. |
Dot(Vector2, Vector2)
Returns the dot product of two vectors.
Declaration
public static float Dot(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| float | The dot product of the two vectors. |
Dot(ref Vector2, ref Vector2, out float)
Returns the dot product of two vectors.
Declaration
public static void Dot(ref Vector2 value1, ref Vector2 value2, out float result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | result | The dot product of two vectors as an output parameter. |
Equals(Vector2)
Indicates whether the current object is equal to another object of the same type.
Declaration
public 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(ref Vector2)
Indicates whether this instance and a specified Vector2 are equal.
Declaration
public bool Equals(ref Vector2 other)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | other | The vector to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Indicates whether this instance and a specified object are equal.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with the current instance. |
Returns
| Type | Description |
|---|---|
| bool | true if |
Overrides
GetHashCode()
Returns the hash code for this instance.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer that is the hash code for this instance. |
Overrides
Hermite(Vector2, Vector2, Vector2, Vector2, float)
Creates a new Vector2 that contains Hermite spline interpolation.
Declaration
public static Vector2 Hermite(Vector2 value1, Vector2 tangent1, Vector2 value2, Vector2 tangent2, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first position vector. |
| Vector2 | tangent1 | The first tangent vector. |
| Vector2 | value2 | The second position vector. |
| Vector2 | tangent2 | The second tangent vector. |
| float | amount | Weighting factor. |
Returns
| Type | Description |
|---|---|
| Vector2 | The Hermite spline interpolation vector. |
Hermite(ref Vector2, ref Vector2, ref Vector2, ref Vector2, float, out Vector2)
Creates a new Vector2 that contains Hermite spline interpolation.
Declaration
public static void Hermite(ref Vector2 value1, ref Vector2 tangent1, ref Vector2 value2, ref Vector2 tangent2, float amount, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first position vector. |
| Vector2 | tangent1 | The first tangent vector. |
| Vector2 | value2 | The second position vector. |
| Vector2 | tangent2 | The second tangent vector. |
| float | amount | Weighting factor. |
| Vector2 | result | The Hermite spline interpolation vector as an output parameter. |
Length()
Returns the length of this Vector2.
Declaration
public float Length()
Returns
| Type | Description |
|---|---|
| float | The length of this Vector2. |
LengthSquared()
Returns the squared length of this Vector2.
Declaration
public float LengthSquared()
Returns
| Type | Description |
|---|---|
| float | The squared length of this Vector2. |
Lerp(Vector2, Vector2, float)
Creates a new Vector2 containing the linear interpolation of the specified vectors.
Declaration
public static Vector2 Lerp(Vector2 value1, Vector2 value2, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | amount | Weighting value (between 0.0 and 1.0). |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the linear interpolation of the specified vectors. |
Lerp(ref Vector2, ref Vector2, float, out Vector2)
Creates a new Vector2 that contains the linear interpolation of the specified vectors.
Declaration
public static void Lerp(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | amount | Weighting value (between 0.0 and 1.0). |
| Vector2 | result | The result of the linear interpolation of the specified vectors as an output parameter. |
Max(Vector2, Vector2)
Creates a new Vector2 that contains the maximal values from the two vectors.
Declaration
public static Vector2 Max(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The Vector2 with the maximal values from the two vectors. |
Max(ref Vector2, ref Vector2, out Vector2)
Creates a new Vector2 that contains the maximal values from the two vectors.
Declaration
public static void Max(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| Vector2 | result | The Vector2 with the maximal values from the two vectors as an output parameter. |
Min(Vector2, Vector2)
Creates a new Vector2 that contains the minimum values from the two vectors.
Declaration
public static Vector2 Min(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The Vector2 with the minimum values from the two vectors. |
Min(ref Vector2, ref Vector2, out Vector2)
Creates a new Vector2 that contains the minimal values from the two vectors.
Declaration
public static void Min(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| Vector2 | result | The Vector2 with the minimal values from the two vectors as an output parameter. |
Multiply(Vector2, Vector2)
Creates a new Vector2 that contains the multiplication of two vectors.
Declaration
public static Vector2 Multiply(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to multiply. |
| Vector2 | value2 | The second vector to multiply. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the vector multiplication. |
Multiply(Vector2, float)
Declaration
public static Vector2 Multiply(Vector2 value1, float scaleFactor)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| float | scaleFactor | Scalar value. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the vector multiplication with the scalar. |
Multiply(ref Vector2, ref Vector2, out Vector2)
Creates a new Vector2 that contains the multiplication of two vectors.
Declaration
public static void Multiply(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to multiply. |
| Vector2 | value2 | The second vector to multiply. |
| Vector2 | result | The result of the vector multiplication as an output parameter. |
Multiply(ref Vector2, float, out Vector2)
Declaration
public static void Multiply(ref Vector2 value1, float scaleFactor, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2. |
| float | scaleFactor | Scalar value. |
| Vector2 | result | The result of the multiplication with a scalar as an output parameter. |
Negate(Vector2)
Creates a new Vector2 that contains the specified vector inversion.
Declaration
public static Vector2 Negate(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The source Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the vector inversion. |
Negate(ref Vector2, out Vector2)
Creates a new Vector2 that contains the specified vector inversion.
Declaration
public static void Negate(ref Vector2 value, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2. |
| Vector2 | result | The result of the vector inversion as an output parameter. |
Normalize()
Turns this Vector2 into a unit vector with the same direction.
Declaration
public float Normalize()
Returns
| Type | Description |
|---|---|
| float | The previous vector length. |
Normalize(Vector2)
Creates a new Vector2 that contains normalized values from another vector.
Declaration
public static Vector2 Normalize(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2. |
Returns
| Type | Description |
|---|---|
| Vector2 | Unit vector. |
Normalize(ref Vector2, out Vector2)
Creates a new Vector2 that contains normalized values from another vector.
Declaration
public static void Normalize(ref Vector2 value, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2. |
| Vector2 | result | Unit vector as an output parameter. |
Project(Vector2, Vector2)
Declaration
public static Vector2 Project(Vector2 vector, Vector2 onVector)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | The Vector2 to project. |
| Vector2 | onVector | The Vector2 to project |
Returns
| Type | Description |
|---|---|
| Vector2 | The Vector2 obtained by projecting |
Remarks
The returned vector is parallel to onVector. The function will return a zero vector if onVector is almost zero.
Project(ref Vector2, ref Vector2, out Vector2)
Declaration
public static void Project(ref Vector2 vector, ref Vector2 onVector, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | The Vector2 to project. |
| Vector2 | onVector | The Vector2 to project |
| Vector2 | result | The Vector2 obtained by projecting |
Remarks
The result vector is parallel to onVector. The function will return a zero vector if onVector is nearly zero.
Reflect(Vector2, Vector2)
Creates a new Vector2 that contains the reflection vector of the given vector and normal.
Declaration
public static Vector2 Reflect(Vector2 vector, Vector2 normal)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Source Vector2. |
| Vector2 | normal | Reflection normal. |
Returns
| Type | Description |
|---|---|
| Vector2 | Reflected vector. |
Reflect(ref Vector2, ref Vector2, out Vector2)
Creates a new Vector2 that contains the reflection vector of the given vector and normal.
Declaration
public static void Reflect(ref Vector2 vector, ref Vector2 normal, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | Source Vector2. |
| Vector2 | normal | Reflection normal. |
| Vector2 | result | Reflected vector as an output parameter. |
Rotate(Vector2, float)
Rotates a vector.
Declaration
public static Vector2 Rotate(Vector2 vector, float angle)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | The vector to be rotated. |
| float | angle | The angle to rotate. |
Returns
| Type | Description |
|---|---|
| Vector2 | The rotated vector. |
Rotate(ref Vector2, float, out Vector2)
Rotates a vector.
Declaration
public static void Rotate(ref Vector2 vector, float angle, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | vector | The vector to be rotated. |
| float | angle | The angle to rotate. |
| Vector2 | result | The rotated vector as an output parameter. |
SmoothDamp(Vector2, Vector2, ref Vector2, float, float)
Changes a vector towards a desired goal over time.
Declaration
public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float gameTime)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | current | The current position. |
| Vector2 | target | The target position we are trying to reach. |
| Vector2 | currentVelocity | The current velocity, modified by the function. |
| float | smoothTime | The time it will take to reach the target. |
| float | gameTime | The current game time (time between the last frame). |
Returns
| Type | Description |
|---|---|
| Vector2 | The smoothed vector. |
SmoothDamp(Vector2, Vector2, ref Vector2, float, float, float)
Changes a vector towards a desired goal over time.
Declaration
public static Vector2 SmoothDamp(Vector2 current, Vector2 target, ref Vector2 currentVelocity, float smoothTime, float maxSpeed, float gameTime)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | current | The current position. |
| Vector2 | target | The target position we are trying to reach. |
| Vector2 | currentVelocity | The current velocity, modified by the function. |
| float | smoothTime | The time it will take to reach the target. |
| float | maxSpeed | The maximum speed. |
| float | gameTime | The current game time (time between the last frame). |
Returns
| Type | Description |
|---|---|
| Vector2 | The smooth vector. |
SmoothStep(Vector2, Vector2, float)
Creates a new Vector2 that contains cubic interpolation of the specified vectors.
Declaration
public static Vector2 SmoothStep(Vector2 value1, Vector2 value2, float amount)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | amount | Weight value. |
Returns
| Type | Description |
|---|---|
| Vector2 | Cubic interpolation of the specified vectors. |
SmoothStep(ref Vector2, ref Vector2, float, out Vector2)
Creates a new Vector2 that contains cubic interpolation of the specified vectors.
Declaration
public static void SmoothStep(ref Vector2 value1, ref Vector2 value2, float amount, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector. |
| Vector2 | value2 | The second vector. |
| float | amount | Weighting value. |
| Vector2 | result | Cubic interpolation of the specified vectors as an output parameter. |
SquareRoot(Vector2)
Returns a vector whose elements are the square root of each of the source vector's elements.
Declaration
public static Vector2 SquareRoot(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The source vector. |
Returns
| Type | Description |
|---|---|
| Vector2 | The square root vector. |
Subtract(Vector2, Vector2)
Declaration
public static Vector2 Subtract(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to subtract. |
| Vector2 | value2 | The second vector to subtract. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of the vector subtraction. |
Subtract(ref Vector2, ref Vector2, out Vector2)
Declaration
public static void Subtract(ref Vector2 value1, ref Vector2 value2, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | The first vector to subtract. |
| Vector2 | value2 | The second vector to subtract. |
| Vector2 | result | The result of the vector subtraction as an output parameter. |
ToString()
Returns the fully qualified type name of this instance.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | The fully qualified type name. |
Overrides
ToVector3(float)
Declaration
public Vector3 ToVector3(float z)
Parameters
| Type | Name | Description |
|---|---|---|
| float | z | The Z value. |
Returns
| Type | Description |
|---|---|
| Vector3 | The Vector3. |
ToVector3(float, Vector3*)
Declaration
public void ToVector3(float z, Vector3* result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | z | The Z value. |
| Vector3* | result | The Vector3 as an output parameter. |
ToVector3(float, out Vector3)
Declaration
public void ToVector3(float z, out Vector3 result)
Parameters
| Type | Name | Description |
|---|---|---|
| float | z | The Z value. |
| Vector3 | result | The Vector3 as an output parameter. |
Transform(Vector2, Matrix4x4)
Transforms a vector by the given matrix.
Declaration
public static Vector2 Transform(Vector2 position, Matrix4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The source vector. |
| Matrix4x4 | matrix | The transformation matrix. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
Transform(Vector2, Quaternion)
Transforms a vector by the given Quaternion rotation value.
Declaration
public static Vector2 Transform(Vector2 value, Quaternion rotation)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | The source vector to be rotated. |
| Quaternion | rotation | The rotation to apply. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
Transform(ref Vector2, ref Matrix4x4, out Vector2)
Transforms a vector by the given matrix.
Declaration
public static void Transform(ref Vector2 position, ref Matrix4x4 matrix, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position | The source vector. |
| Matrix4x4 | matrix | The transformation matrix. |
| Vector2 | result | The transformed vector. |
Transform(ref Vector2, ref Quaternion, out Vector2)
Creates a new Vector2 that contains a transformation of a 2D vector by the specified Quaternion, representing the rotation.
Declaration
public static void Transform(ref Vector2 value, ref Quaternion rotation, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2. |
| Quaternion | rotation | The Quaternion which contains the rotation transformation. |
| Vector2 | result | Transformed Vector2 as an output parameter. |
Transform(Vector2[], ref Matrix4x4, Vector2[])
Applies a transformation to all vectors within an array of Vector2 by the specified Matrix4x4 and places the results in another array.
Declaration
public static void Transform(Vector2[] sourceArray, ref Matrix4x4 matrix, Vector2[] destinationArray)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2[] | sourceArray | Source array. |
| Matrix4x4 | matrix | The transformation Matrix4x4. |
| Vector2[] | destinationArray | Destination array. |
Transform(Vector2[], int, ref Matrix4x4, Vector2[], int, int)
Applies transformation on vectors within an array of Vector2 using the specified Matrix4x4 and places the results in another array.
Declaration
public static void Transform(Vector2[] sourceArray, int sourceIndex, ref Matrix4x4 matrix, Vector2[] destinationArray, int destinationIndex, int length)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2[] | sourceArray | Source array. |
| int | sourceIndex | The starting index of transformation in the source array. |
| Matrix4x4 | matrix | The transformation Matrix4x4. |
| Vector2[] | destinationArray | Destination array. |
| int | destinationIndex | The starting index in the destination array, where the first Vector2 should be written. |
| int | length | The number of vectors to be transformed. |
TransformNormal(Vector2, Matrix4x4)
Transforms a vector normal by the given matrix.
Declaration
public static Vector2 TransformNormal(Vector2 normal, Matrix4x4 matrix)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | normal | The source vector. |
| Matrix4x4 | matrix | The transformation matrix. |
Returns
| Type | Description |
|---|---|
| Vector2 | The transformed vector. |
TransformNormal(ref Vector2, ref Matrix4x4, out Vector2)
Transforms a vector normal by the given matrix.
Declaration
public static void TransformNormal(ref Vector2 normal, ref Matrix4x4 matrix, out Vector2 result)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | normal | The source vector. |
| Matrix4x4 | matrix | The transformation matrix. |
| Vector2 | result | The transformed vector. |
Operators
operator +(Vector2, Vector2)
Adds two vectors.
Declaration
public static Vector2 operator +(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2 on the left of the addition sign. |
| Vector2 | value2 | Source Vector2 on the right of the addition sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Sum of the vectors. |
operator /(Vector2, Vector2)
Declaration
public static Vector2 operator /(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2 on the left of the division sign. |
| Vector2 | value2 | Divisor Vector2 on the right of the division sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of dividing the vectors. |
operator /(Vector2, float)
Divides the components of a Vector2 by a scalar.
Declaration
public static Vector2 operator /(Vector2 value1, float divider)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2 on the left of the division sign. |
| float | divider | Divisor scalar on the right of the division sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | The result of dividing a vector by a scalar. |
operator ==(Vector2, Vector2)
Compares whether two Vector2 instances are equal.
Declaration
public static bool operator ==(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Vector2 instance on the left of the equal sign. |
| Vector2 | value2 | Vector2 instance on the right of the equal sign. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(Vector2, Vector2)
Compares whether two Vector2 instances are not equal.
Declaration
public static bool operator !=(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Vector2 instance on the left of the not equal sign. |
| Vector2 | value2 | Vector2 instance on the right of the not equal sign. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator *(Vector2, Vector2)
Multiplies the components of two vectors by each other.
Declaration
public static Vector2 operator *(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2 on the left of the multiplication sign. |
| Vector2 | value2 | Source Vector2 on the right of the multiplication sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the vector multiplication. |
operator *(Vector2, float)
Multiplies the components of a vector by a scalar.
Declaration
public static Vector2 operator *(Vector2 value, float scaleFactor)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2 on the left of the multiplication sign. |
| float | scaleFactor | Scalar value on the right of the multiplication sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the vector multiplication with a scalar. |
operator *(float, Vector2)
Multiplies the components of a vector by a scalar.
Declaration
public static Vector2 operator *(float scaleFactor, Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | scaleFactor | Scalar value on the left of the multiplication sign. |
| Vector2 | value | Source Vector2 on the right of the multiplication sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the vector multiplication with a scalar. |
operator -(Vector2, Vector2)
Declaration
public static Vector2 operator -(Vector2 value1, Vector2 value2)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value1 | Source Vector2 on the left of the subtraction sign. |
| Vector2 | value2 | Source Vector2 on the right of the subtraction sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the vector subtraction. |
operator -(Vector2)
Inverts values in the specified Vector2.
Declaration
public static Vector2 operator -(Vector2 value)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | value | Source Vector2 on the right of the sub sign. |
Returns
| Type | Description |
|---|---|
| Vector2 | Result of the inversion. |