Struct Vector2
- Namespace
- Lime
- Assembly
- Lime.dll
Representation of 2D vectors and points.
public struct Vector2 : IEquatable<Vector2>
- Implements
- Inherited Members
Constructors
Vector2(float)
public Vector2(float xy)
Parameters
xy
float
Vector2(float, float)
public Vector2(float x, float y)
Parameters
Fields
Down
Returns a vector with components 0, 1.
public static readonly Vector2 Down
Field Value
East
Returns a vector with components 1, 0.
public static readonly Vector2 East
Field Value
Half
Returns a vector with components 0.5, 0.5.
public static readonly Vector2 Half
Field Value
Left
Returns a vector with components -1, 0.
public static readonly Vector2 Left
Field Value
LeftDown
public static readonly Vector2 LeftDown
Field Value
LeftUp
public static readonly Vector2 LeftUp
Field Value
NaN
Returns a vector with components NaN, NaN.
public static readonly Vector2 NaN
Field Value
NegativeInfinity
Returns a vector with components -Infinity, -Infinity.
public static readonly Vector2 NegativeInfinity
Field Value
North
Returns a vector with components 0, -1.
public static readonly Vector2 North
Field Value
One
Returns a vector with components 1, 1.
public static readonly Vector2 One
Field Value
PositiveInfinity
Returns a vector with components Infinity, Infinity.
public static readonly Vector2 PositiveInfinity
Field Value
Right
Returns a vector with components 1, 0.
public static readonly Vector2 Right
Field Value
RightDown
public static readonly Vector2 RightDown
Field Value
RightUp
public static readonly Vector2 RightUp
Field Value
South
Returns a vector with components 0, 1.
public static readonly Vector2 South
Field Value
Up
Returns a vector with components 0, -1.
public static readonly Vector2 Up
Field Value
West
Returns a vector with components -1, 0.
public static readonly Vector2 West
Field Value
X
[YuzuMember("0")]
public float X
Field Value
Y
[YuzuMember("1")]
public float Y
Field Value
Zero
Returns a vector with components 0, 0.
public static readonly Vector2 Zero
Field Value
Properties
Atan2Deg
Returns the arctangent value of the current vector in the range of (-180, 180].
public float Atan2Deg { get; }
Property Value
Atan2Rad
Returns the arctangent value of the current vector in the range of (-Pi, Pi].
public float Atan2Rad { get; }
Property Value
this[int]
Gets or sets the vector component by its index.
public float this[int component] { get; set; }
Parameters
component
int
Property Value
Length
public float Length { get; }
Property Value
Normalized
Returns this Vector2 as a unit vector with the same direction.
public Vector2 Normalized { get; }
Property Value
SqrLength
public float SqrLength { get; }
Property Value
Methods
AngleDeg(Vector2, Vector2)
Gets the angle (in degrees) between two Vector2 instances.
public static float AngleDeg(Vector2 value1, Vector2 value2)
Parameters
Returns
AngleRad(Vector2, Vector2)
Gets the angle (in radians) between two Vector2 instances.
public static float AngleRad(Vector2 value1, Vector2 value2)
Parameters
Returns
Ceiling(Vector2)
public static Vector2 Ceiling(Vector2 value)
Parameters
value
Vector2
Returns
Clamp(Vector2, Vector2, Vector2)
public static Vector2 Clamp(Vector2 value, Vector2 a, Vector2 b)
Parameters
Returns
CosSin(float)
Creates a new Vector2 that represents cosine and sine of specified direction.
public static Vector2 CosSin(float radians)
Parameters
radians
floatAzimuth of direction (in radians).
Returns
CosSinRough(float)
Creates a new Vector2 that represents cosine and sine of specified direction.
public static Vector2 CosSinRough(float radians)
Parameters
radians
floatAzimuth of direction (in radians).
Returns
CrossProduct(Vector2, Vector2)
public static float CrossProduct(Vector2 value1, Vector2 value2)
Parameters
Returns
Deconstruct(out float, out float)
public readonly void Deconstruct(out float x, out float y)
Parameters
Distance(Vector2, Vector2)
Returns the distance between two vectors.
public static float Distance(Vector2 value1, Vector2 value2)
Parameters
Returns
DotProduct(Vector2, Vector2)
public static float DotProduct(Vector2 value1, Vector2 value2)
Parameters
Returns
Equals(Vector2)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Vector2 other)
Parameters
other
Vector2An object to compare with this object.
Returns
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
Floor(Vector2)
public static Vector2 Floor(Vector2 value)
Parameters
value
Vector2
Returns
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Lerp(float, Vector2, Vector2)
Creates a new Vector2 that contains linear interpolation of the specified vectors.
public static Vector2 Lerp(float amount, Vector2 value1, Vector2 value2)
Parameters
amount
floatWeighting value(between 0.0 and 1.0).
value1
Vector2The first vector.
value2
Vector2The second vector.
Returns
Max(Vector2, Vector2)
public static Vector2 Max(Vector2 a, Vector2 b)
Parameters
Returns
Min(Vector2, Vector2)
public static Vector2 Min(Vector2 a, Vector2 b)
Parameters
Returns
Parse(string)
Converts the string representation of the number to its Vector2 equivalent.
public static Vector2 Parse(string s)
Parameters
s
stringThe string containing the vector to convert.
Returns
Examples
"12, 34".
RotateDeg(Vector2, float)
Creates new Vector2 that is turned around point (0, 0).
public static Vector2 RotateDeg(Vector2 value, float degrees)
Parameters
Returns
RotateDegRough(Vector2, float)
Creates new Vector2 that is turned around point (0, 0).
public static Vector2 RotateDegRough(Vector2 value, float degrees)
Parameters
Returns
RotateRad(Vector2, float)
Creates new Vector2 that is turned around point (0, 0).
public static Vector2 RotateRad(Vector2 value, float radians)
Parameters
Returns
RotateRadRough(Vector2, float)
Creates new Vector2 that is turned around point (0, 0).
public static Vector2 RotateRadRough(Vector2 value, float radians)
Parameters
Returns
Round(Vector2)
public static Vector2 Round(Vector2 value)
Parameters
value
Vector2
Returns
ToString()
public override string ToString()
Returns
ToString(IFormatProvider)
public string ToString(IFormatProvider format)
Parameters
format
IFormatProvider
Returns
Truncate(Vector2)
public static Vector2 Truncate(Vector2 value)
Parameters
value
Vector2
Returns
TryParse(string, out Vector2)
Converts the string representation of the vector to its Vector2 equivalent. The return value indicates whether the conversion succeeded.
public static bool TryParse(string s, out Vector2 vector)
Parameters
s
stringThe string containing the vector to convert.
vector
Vector2The result of conversion if it succeeds, Zero otherwise.
Returns
Examples
"12, 34".
Operators
operator +(Vector2, Vector2)
public static Vector2 operator +(Vector2 lhs, Vector2 rhs)
Parameters
Returns
operator /(Vector2, Vector2)
public static Vector2 operator /(Vector2 lhs, Vector2 rhs)
Parameters
Returns
operator /(Vector2, float)
public static Vector2 operator /(Vector2 lhs, float rhs)
Parameters
Returns
operator ==(Vector2, Vector2)
public static bool operator ==(Vector2 lhs, Vector2 rhs)
Parameters
Returns
explicit operator IntVector2(Vector2)
public static explicit operator IntVector2(Vector2 value)
Parameters
value
Vector2
Returns
explicit operator Size(Vector2)
public static explicit operator Size(Vector2 value)
Parameters
value
Vector2
Returns
explicit operator Vector3(Vector2)
public static explicit operator Vector3(Vector2 value)
Parameters
value
Vector2
Returns
operator !=(Vector2, Vector2)
public static bool operator !=(Vector2 lhs, Vector2 rhs)
Parameters
Returns
operator *(Vector2, Vector2)
public static Vector2 operator *(Vector2 lhs, Vector2 rhs)
Parameters
Returns
operator *(Vector2, float)
public static Vector2 operator *(Vector2 lhs, float rhs)
Parameters
Returns
operator *(float, Vector2)
public static Vector2 operator *(float lhs, Vector2 rhs)
Parameters
Returns
operator -(Vector2, Vector2)
public static Vector2 operator -(Vector2 lhs, Vector2 rhs)
Parameters
Returns
operator -(Vector2)
public static Vector2 operator -(Vector2 value)
Parameters
value
Vector2