Struct Vector2
- Namespace
- Alis.Core.Aspect.Math.Vector
- Assembly
- Alis.dll
The vector
[Serializable]
public struct Vector2 : IEquatable<Vector2>, IFormattable, ISerializableImplements
Inherited Members
Extension Methods
Constructors
Vector2(float)
Creates a new Alis.Core.Aspect.Math.Vector.Vector2 object whose two elements have the same value.
public Vector2(float value)Parameters
valuefloat-
The value to assign to both elements.
Vector2(float, float)
Creates a vector whose elements have the specified values.
public Vector2(float x, float y)Parameters
xfloat-
The value to assign to the Alis.Core.Aspect.Math.Vector.Vector2.X field.
yfloat-
The value to assign to the Alis.Core.Aspect.Math.Vector.Vector2.Y field.
Properties
One
Gets a vector whose 2 elements are equal to one.
public static Vector2 One { get; }Property Value
UnitX
Gets the vector (1,0).
public static Vector2 UnitX { get; }Property Value
UnitY
Gets the vector (0,1).
public static Vector2 UnitY { get; }Property Value
X
The X component of the vector.
public float X { readonly get; set; }Property Value
Y
The Y component of the vector.
public float Y { readonly get; set; }Property Value
Zero
Returns a vector whose 2 elements are equal to zero.
public static Vector2 Zero { get; }Property Value
Methods
Abs(Vector2)
Returns a vector whose elements are the absolute values of each of the specified vector's elements.
public static Vector2 Abs(Vector2 value)Parameters
valueVector2-
A vector.
Returns
- Vector2
-
The absolute value vector.
Add(Vector2, Vector2)
Adds two vectors together.
public static Vector2 Add(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The summed vector.
Add(ref Vector2, ref Vector2, out Vector2)
Adds the left
public static void Add(ref Vector2 left, ref Vector2 right, out Vector2 result)Parameters
Clamp(Vector2, Vector2, Vector2)
Restricts a vector between a minimum and a maximum value.
public static Vector2 Clamp(Vector2 value1, Vector2 min, Vector2 max)Parameters
value1Vector2-
The vector to restrict.
minVector2-
The minimum value.
maxVector2-
The maximum value.
Returns
- Vector2
-
The restricted vector.
CopyTo(float[], int)
Copies the elements of the vector to a specified array starting at a specified index position.
public void CopyTo(float[] array, int index = 0)Parameters
arrayfloat[]-
The destination array.
indexint-
The index at which to copy the first element of the vector.
Remarks
array must have a sufficient number of elements to accommodate the two vector elements. In
other words, elements index and index + 1 must already exist in
array.
Exceptions
- ArgumentNullException
-
arrayis null. - ArgumentException
-
The number of elements in the current instance is greater than in the array.
- ArgumentOutOfRangeException
-
indexis less than zero. -or-indexis greater than or equal to the array length. - RankException
-
arrayis multidimensional.
Distance(Vector2, Vector2)
Computes the Euclidean distance between the two given points.
public static float Distance(Vector2 value1, Vector2 value2)Parameters
Returns
- float
-
The distance.
Distance(ref Vector2, ref Vector2, out float)
Distances the v 1
public static void Distance(ref Vector2 v1, ref Vector2 v2, out float result)Parameters
DistanceSquared(Vector2, Vector2)
Returns the Euclidean distance squared between two specified points.
public static float DistanceSquared(Vector2 value1, Vector2 value2)Parameters
Returns
- float
-
The distance squared.
DistanceSquared(ref Vector2, ref Vector2, out float)
Distances the squared using the specified v 1
public static void DistanceSquared(ref Vector2 v1, ref Vector2 v2, out float result)Parameters
Divide(Vector2, Vector2)
Divides the first vector by the second.
public static Vector2 Divide(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The vector resulting from the division.
Divide(Vector2, float)
Divides the specified vector by a specified scalar value.
public static Vector2 Divide(Vector2 left, float divisor)Parameters
Returns
- Vector2
-
The vector that results from the division.
Divide(ref Vector2, float, out Vector2)
Divides the left
public static void Divide(ref Vector2 left, float right, out Vector2 result)Parameters
Dot(Vector2, Vector2)
Returns the dot product of two vectors.
public static float Dot(Vector2 value1, Vector2 value2)Parameters
Returns
- float
-
The dot product.
Dot(ref Vector2, ref Vector2, out float)
Dots the left
public static void Dot(ref Vector2 left, ref Vector2 right, out float result)Parameters
Equals(object)
Returns a value that indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)Parameters
objobject-
The object to compare with the current instance.
Returns
- bool
-
true if the current instance and
objare equal; otherwise, false. Ifobjis null, the method returns false.
Remarks
The current instance and obj are equal if obj is a
Alis.Core.Aspect.Math.Vector.Vector2 object and their Alis.Core.Aspect.Math.Vector.Vector2.X and Alis.Core.Aspect.Math.Vector.Vector2.Y elements are equal.
Equals(Vector2)
Returns a value that indicates whether this instance and another vector are equal.
public bool Equals(Vector2 other)Parameters
otherVector2-
The other vector.
Returns
Remarks
Two vectors are equal if their Alis.Core.Aspect.Math.Vector.Vector2.X and Alis.Core.Aspect.Math.Vector.Vector2.Y elements are equal.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()Returns
- int
-
The hash code.
GetObjectData(SerializationInfo, StreamingContext)
Gets the object data using the specified info
public void GetObjectData(SerializationInfo info, StreamingContext context)Parameters
infoSerializationInfo-
The info
contextStreamingContext-
The context
Length()
Returns the length of the vector.
public float Length()Returns
- float
-
The vector's length.
LengthSquared()
Returns the length of the vector squared.
public float LengthSquared()Returns
- float
-
The vector's length squared.
Remarks
This operation offers better performance than a call to the Alis.Core.Aspect.Math.Vector.Vector2.Length method.
LerP(Vector2, Vector2, float)
Performs a linear interpolation between two vectors based on the given weighting.
public static Vector2 LerP(Vector2 value1, Vector2 value2, float amount)Parameters
value1Vector2-
The first vector.
value2Vector2-
The second vector.
amountfloat-
A value between 0 and 1 that indicates the weight of
value2.
Returns
- Vector2
-
The interpolated vector.
Remarks
Max(Vector2, Vector2)
Returns a vector whose elements are the maximum of each of the pairs of elements in two specified vectors.
public static Vector2 Max(Vector2 value1, Vector2 value2)Parameters
Returns
- Vector2
-
The maximized vector.
Max(ref Vector2, ref Vector2, out Vector2)
Maxes the v 1
public static void Max(ref Vector2 v1, ref Vector2 v2, out Vector2 result)Parameters
Min(Vector2, Vector2)
Returns a vector whose elements are the minimum of each of the pairs of elements in two specified vectors.
public static Vector2 Min(Vector2 value1, Vector2 value2)Parameters
Returns
- Vector2
-
The minimized vector.
Min(ref Vector2, ref Vector2, out Vector2)
Mins the v 1
public static void Min(ref Vector2 v1, ref Vector2 v2, out Vector2 result)Parameters
Multiply(Vector2, Vector2)
Returns a new vector whose values are the product of each pair of elements in two specified vectors.
public static Vector2 Multiply(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The element-wise product vector.
Multiply(Vector2, float)
Multiplies a vector by a specified scalar.
public static Vector2 Multiply(Vector2 left, float right)Parameters
Returns
- Vector2
-
The scaled vector.
Multiply(float, Vector2)
Multiplies a scalar value by a specified vector.
public static Vector2 Multiply(float left, Vector2 right)Parameters
Returns
- Vector2
-
The scaled vector.
Multiply(ref Vector2, ref Vector2, out Vector2)
Multiplies the left
public static void Multiply(ref Vector2 left, ref Vector2 right, out Vector2 result)Parameters
Multiply(ref Vector2, float, out Vector2)
Multiplies the left
public static void Multiply(ref Vector2 left, float right, out Vector2 result)Parameters
Negate(Vector2)
Negates a specified vector.
public static Vector2 Negate(Vector2 value)Parameters
valueVector2-
The vector to negate.
Returns
- Vector2
-
The negated vector.
Normalize(Vector2)
Returns a vector with the same direction as the specified vector, but with a length of one.
public static Vector2 Normalize(Vector2 value)Parameters
valueVector2-
The vector to normalize.
Returns
- Vector2
-
The normalized vector.
Normalize()
Normalizes this instance
public void Normalize()Reflect(Vector2, Vector2)
Returns the reflection of a vector off a surface that has the specified normal.
public static Vector2 Reflect(Vector2 vector, Vector2 normal)Parameters
Returns
- Vector2
-
The reflected vector.
SquareRoot(Vector2)
Returns a vector whose elements are the square root of each of a specified vector's elements.
public static Vector2 SquareRoot(Vector2 value)Parameters
valueVector2-
A vector.
Returns
- Vector2
-
The square root vector.
Subtract(Vector2, Vector2)
Subtracts the second vector from the first.
public static Vector2 Subtract(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The difference vector.
Subtract(ref Vector2, ref Vector2, out Vector2)
Subtracts the left
public static void Subtract(ref Vector2 left, ref Vector2 right, out Vector2 result)Parameters
ToString(string, IFormatProvider)
Returns the string representation of the current instance using the specified format string to format individual elements and the specified format provider to define culture-specific formatting.
public string ToString(string format, IFormatProvider formatProvider)Parameters
formatstring-
A standard or custom numeric format string that defines the format of individual elements.
formatProviderIFormatProvider-
A format provider that supplies culture-specific formatting information.
Returns
- string
-
The string representation of the current instance.
Remarks
This method returns a string in which each element of the vector is formatted using format
and formatProvider. The "<" and ">" characters are used to begin and end the string, and
the format provider's System.Globalization.NumberFormatInfo.NumberGroupSeparator property followed
by a space is used to separate each element.
ToString(string, CultureInfo)
Returns the string using the specified f 2
public string ToString(string f2, CultureInfo cultureInfo)Parameters
f2string-
The
cultureInfoCultureInfo-
The culture info
Returns
- string
-
The string
Transform(Vector2, Matrix3X2)
Transforms a vector by a specified 3x2 matrix.
public static Vector2 Transform(Vector2 position, Matrix3X2 matrix)Parameters
Returns
- Vector2
-
The transformed vector.
Transform(Vector2, Matrix4X4)
Transforms a vector by a specified 4x4 matrix.
public static Vector2 Transform(Vector2 position, Matrix4X4 matrix)Parameters
Returns
- Vector2
-
The transformed vector.
Transform(Vector2, Quaternion)
Transforms a vector by the specified Quaternion rotation value.
public static Vector2 Transform(Vector2 value, Quaternion rotation)Parameters
valueVector2-
The vector to rotate.
rotationQuaternion-
The rotation to apply.
Returns
- Vector2
-
The transformed vector.
TransformNormal(Vector2, Matrix3X2)
Transforms a vector normal by the given 3x2 matrix.
public static Vector2 TransformNormal(Vector2 normal, Matrix3X2 matrix)Parameters
Returns
- Vector2
-
The transformed vector.
TransformNormal(Vector2, Matrix4X4)
Transforms a vector normal by the given 4x4 matrix.
public static Vector2 TransformNormal(Vector2 normal, Matrix4X4 matrix)Parameters
Returns
- Vector2
-
The transformed vector.
Operators
operator +(Vector2, Vector2)
Adds two vectors together.
public static Vector2 operator +(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The summed vector.
Remarks
The Alis.Core.Aspect.Math.Vector.Vector2.op_Addition(Alis.Core.Aspect.Math.Vector.Vector2,Alis.Core.Aspect.Math.Vector.Vector2) method defines the addition operation for Alis.Core.Aspect.Math.Vector.Vector2 objects.
operator /(Vector2, Vector2)
Divides the first vector by the second.
public static Vector2 operator /(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The vector that results from dividing
leftbyright.
operator /(Vector2, float)
Divides the specified vector by a specified scalar value.
public static Vector2 operator /(Vector2 value1, float value2)Parameters
Returns
- Vector2
-
The result of the division.
operator ==(Vector2, Vector2)
Returns a value that indicates whether each pair of elements in two specified vectors is equal.
public static bool operator ==(Vector2 left, Vector2 right)Parameters
Returns
Remarks
Two Alis.Core.Aspect.Math.Vector.Vector2 objects are equal if each value in left is equal to the
corresponding value in right.
operator !=(Vector2, Vector2)
Returns a value that indicates whether two specified vectors are not equal.
public static bool operator !=(Vector2 left, Vector2 right)Parameters
Returns
operator *(Vector2, Vector2)
Returns a new vector whose values are the product of each pair of elements in two specified vectors.
public static Vector2 operator *(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The element-wise product vector.
operator *(Vector2, float)
Multiplies the specified vector by the specified scalar value.
public static Vector2 operator *(Vector2 left, float right)Parameters
Returns
- Vector2
-
The scaled vector.
operator *(float, Vector2)
Multiplies the scalar value by the specified vector.
public static Vector2 operator *(float left, Vector2 right)Parameters
Returns
- Vector2
-
The scaled vector.
operator -(Vector2, Vector2)
Subtracts the second vector from the first.
public static Vector2 operator -(Vector2 left, Vector2 right)Parameters
Returns
- Vector2
-
The vector that results from subtracting
rightfromleft.
Remarks
The Alis.Core.Aspect.Math.Vector.Vector2.op_Subtraction(Alis.Core.Aspect.Math.Vector.Vector2,Alis.Core.Aspect.Math.Vector.Vector2) method defines the subtraction operation for Alis.Core.Aspect.Math.Vector.Vector2 objects.
operator -(Vector2)
Negates the specified vector.
public static Vector2 operator -(Vector2 value)Parameters
valueVector2-
The vector to negate.
Returns
- Vector2
-
The negated vector.
Remarks
The Alis.Core.Aspect.Math.Vector.Vector2.op_UnaryNegation(Alis.Core.Aspect.Math.Vector.Vector2) method defines the unary negation operation for Alis.Core.Aspect.Math.Vector.Vector2 objects.