Struct Vector2
2-Component Vector Structure.
Assembly: Chroma.Mono.dll
Syntax
public struct Vector2 : IEquatable<Vector2>
Constructors
Vector2(Single)
Constructs a new vector with an initial scalar (sets x and y to scalar).
Declaration
public Vector2(float scalar)
Parameters
Type |
Name |
Description |
System.Single |
scalar |
|
Vector2(Single, Single)
Constructs a new vector with intial values.
Declaration
public Vector2(float x, float y)
Parameters
Type |
Name |
Description |
System.Single |
x |
|
System.Single |
y |
|
Fields
Down
Declaration
public static Vector2 Down
Field Value
Left
Declaration
public static Vector2 Left
Field Value
One
Declaration
public static Vector2 One
Field Value
Right
Declaration
public static Vector2 Right
Field Value
Up
Declaration
Field Value
X
X component of the vector.
Declaration
Field Value
Type |
Description |
System.Single |
|
Y
Y component of the vector.
Declaration
Field Value
Type |
Description |
System.Single |
|
Zero
Declaration
public static Vector2 Zero
Field Value
Methods
Angle(Vector2, Vector2)
Calculates the angle between two vectors.
Declaration
public static float Angle(Vector2 a, Vector2 b)
Parameters
Returns
Type |
Description |
System.Single |
|
Clamp(Vector2, Vector2)
Clamps the this vector between two vectors. The function performes a component-wise clamp, meaning clamping each component is done independently.
Declaration
public void Clamp(Vector2 min, Vector2 max)
Parameters
Cos(Vector2)
Computes the cosine of a vector, component-wise.
Declaration
public static Vector2 Cos(Vector2 vector)
Parameters
Type |
Name |
Description |
Vector2 |
vector |
|
Returns
Distance(Vector2)
Calculates the distance between this and another vector.
Declaration
public float Distance(Vector2 other)
Parameters
Type |
Name |
Description |
Vector2 |
other |
Other vector to calculate distance.
|
Returns
Type |
Description |
System.Single |
Distance between this and other.
|
Distance(Vector2, Vector2)
Calculates the distance between two vectors.
Declaration
public static float Distance(Vector2 first, Vector2 second)
Parameters
Returns
Type |
Description |
System.Single |
Distance between the two vectors.
|
Dot(Vector2, Vector2)
Calculates the dot product between two vectors.
Declaration
public static float Dot(Vector2 a, Vector2 b)
Parameters
Returns
Type |
Description |
System.Single |
|
Equals(Vector2)
Calculates equality between two vectors.
Declaration
public bool Equals(Vector2 right)
Parameters
Type |
Name |
Description |
Vector2 |
right |
|
Returns
Type |
Description |
System.Boolean |
|
Equals(Object)
Calculates equality between two vectors.
Declaration
public override bool Equals(object obj)
Parameters
Type |
Name |
Description |
System.Object |
obj |
|
Returns
Type |
Description |
System.Boolean |
|
Overrides
System.ValueType.Equals(System.Object)
GetHashCode()
Computes the hash code of the vector.
Declaration
public override int GetHashCode()
Returns
Type |
Description |
System.Int32 |
|
Overrides
System.ValueType.GetHashCode()
Length()
Calculates the length of the vector.
Declaration
Returns
Type |
Description |
System.Single |
|
Lerp(Vector2, Vector2, Single)
Linear interpolation between two vectors.
Declaration
public static Vector2 Lerp(Vector2 from, Vector2 to, float delta)
Parameters
Type |
Name |
Description |
Vector2 |
from |
Starting vector
|
Vector2 |
to |
Ending vector
|
System.Single |
delta |
Delta time
|
Returns
Normalize()
Declaration
Normalized()
Returns a normalized version of this vector.
Note: This does not normalize this vector, but rather returns a copy which is normalized.
See Normalize
to normalize this vector.
Declaration
public Vector2 Normalized()
Returns
Sin(Vector2)
Computes the sine of a vector, component-wise.
Declaration
public static Vector2 Sin(Vector2 vector)
Parameters
Type |
Name |
Description |
Vector2 |
vector |
|
Returns
ToString()
Creates a formatted string containing the components of the vector.
Declaration
public override string ToString()
Returns
Type |
Description |
System.String |
|
Overrides
System.ValueType.ToString()
Operators
Addition(Vector2, Vector2)
Declaration
public static Vector2 operator +(Vector2 left, Vector2 right)
Parameters
Returns
Addition(Vector2, Single)
Component-wise addition of a value to a vector.
Declaration
public static Vector2 operator +(Vector2 left, float right)
Parameters
Type |
Name |
Description |
Vector2 |
left |
|
System.Single |
right |
|
Returns
Division(Vector2, Vector2)
Declaration
public static Vector2 operator /(Vector2 left, Vector2 right)
Parameters
Returns
Division(Vector2, Single)
Division of a vector by a scalar.
Declaration
public static Vector2 operator /(Vector2 left, float scalar)
Parameters
Type |
Name |
Description |
Vector2 |
left |
|
System.Single |
scalar |
|
Returns
Equality(Vector2, Vector2)
Calculates equality between two vectors.
Declaration
public static bool operator ==(Vector2 left, Vector2 right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Inequality(Vector2, Vector2)
Calculates non-equality between two vectors.
Declaration
public static bool operator !=(Vector2 left, Vector2 right)
Parameters
Returns
Type |
Description |
System.Boolean |
|
Multiply(Vector2, Vector2)
Multipication of two vectors.
Declaration
public static Vector2 operator *(Vector2 left, Vector2 right)
Parameters
Returns
Multiply(Vector2, Single)
Multiplication by scalar.
Declaration
public static Vector2 operator *(Vector2 left, float scalar)
Parameters
Type |
Name |
Description |
Vector2 |
left |
|
System.Single |
scalar |
|
Returns
Multiply(Single, Vector2)
Declaration
public static Vector2 operator *(float scalar, Vector2 right)
Parameters
Type |
Name |
Description |
System.Single |
scalar |
|
Vector2 |
right |
|
Returns
Subtraction(Vector2, Vector2)
Subtraction of two vectors.
Declaration
public static Vector2 operator -(Vector2 left, Vector2 right)
Parameters
Returns
UnaryNegation(Vector2)
Declaration
public static Vector2 operator -(Vector2 vector)
Parameters
Type |
Name |
Description |
Vector2 |
vector |
|
Returns