SHVDN  v3
An ASI plugin for Grand Theft Auto V, which allows running scripts written in any .NET language in-game. Developed by crosire https://github.com/crosire/scripthookvdotnet/
GTA.Math.Vector2 Struct Reference
Inheritance diagram for GTA.Math.Vector2:

Public Member Functions

 Vector2 (float x, float y)
 Initializes a new instance of the Vector2 class. More...
 
float Length ()
 Calculates the length of the vector. More...
 
float LengthSquared ()
 Calculates the squared length of the vector. More...
 
void Normalize ()
 Converts the vector into a unit vector. More...
 
float DistanceTo (Vector2 position)
 Calculates the distance between two vectors. More...
 
float DistanceToSquared (Vector2 position)
 Calculates the squared distance between two vectors. More...
 
float ToHeading ()
 Converts a vector to a heading. More...
 
override string ToString ()
 Converts the value of the object to its equivalent string representation. More...
 
string ToString (string format)
 Converts the value of the object to its equivalent string representation. More...
 
override int GetHashCode ()
 Returns the hash code for this instance. More...
 
override bool Equals (object obj)
 Returns a value that indicates whether the current instance is equal to a specified object. More...
 
bool Equals (Vector2 other)
 Returns a value that indicates whether the current instance is equal to the specified object. More...
 

Static Public Member Functions

static float Distance (Vector2 position1, Vector2 position2)
 Calculates the distance between two vectors. More...
 
static float DistanceSquared (Vector2 position1, Vector2 position2)
 Calculates the squared distance between two vectors. More...
 
static float Angle (Vector2 from, Vector2 to)
 Returns the angle in degrees between from and to. The angle returned is always the acute angle between the two vectors. More...
 
static float SignedAngle (Vector2 from, Vector2 to)
 Returns the signed angle in degrees between from and to. More...
 
static Vector2 RandomXY ()
 Returns a new normalized vector with random X and Y components. More...
 
static Vector2 Add (Vector2 left, Vector2 right)
 Adds two vectors. More...
 
static Vector2 Subtract (Vector2 left, Vector2 right)
 Subtracts two vectors. More...
 
static Vector2 Multiply (Vector2 value, float scale)
 Scales a vector by the given value. More...
 
static Vector2 Multiply (Vector2 left, Vector2 right)
 Multiplies a vector with another by performing component-wise multiplication. More...
 
static Vector2 Divide (Vector2 value, float scale)
 Scales a vector by the given value. More...
 
static Vector2 Negate (Vector2 value)
 Reverses the direction of a given vector. More...
 
static Vector2 Clamp (Vector2 value, Vector2 min, Vector2 max)
 Restricts a value to be within a specified range. More...
 
static Vector2 Lerp (Vector2 start, Vector2 end, float amount)
 Performs a linear interpolation between two vectors. More...
 
static Vector2 Normalize (Vector2 vector)
 Converts the vector into a unit vector. More...
 
static float Dot (Vector2 left, Vector2 right)
 Calculates the dot product of two vectors. More...
 
static Vector2 Reflect (Vector2 vector, Vector2 normal)
 Returns the reflection of a vector off a surface that has the specified normal. More...
 
static Vector2 Minimize (Vector2 left, Vector2 right)
 Returns a vector containing the smallest components of the specified vectors. More...
 
static Vector2 Maximize (Vector2 left, Vector2 right)
 Returns a vector containing the largest components of the specified vectors. More...
 
static Vector2 operator+ (Vector2 left, Vector2 right)
 Adds two vectors. More...
 
static Vector2 operator- (Vector2 left, Vector2 right)
 Subtracts two vectors. More...
 
static Vector2 operator- (Vector2 value)
 Reverses the direction of a given vector. More...
 
static Vector2 operator* (Vector2 vector, float scale)
 Scales a vector by the given value. More...
 
static Vector2 operator* (float scale, Vector2 vector)
 Scales a vector by the given value. More...
 
static Vector2 operator/ (Vector2 vector, float scale)
 Scales a vector by the given value. More...
 
static bool operator== (Vector2 left, Vector2 right)
 Tests for equality between two objects. More...
 
static bool operator!= (Vector2 left, Vector2 right)
 Tests for inequality between two objects. More...
 
static implicit operator Vector3 (Vector2 vector)
 Converts a Vector2 to a Vector3 implicitly. More...
 

Public Attributes

float X
 Gets or sets the X component of the vector. More...
 
float Y
 Gets or sets the Y component of the vector. More...
 
Vector2 Normalized => Normalize(new Vector2(X, Y))
 Returns this vector with a magnitude of 1. More...
 

Static Public Attributes

static Vector2 Zero => new Vector2(0.0f, 0.0f)
 Returns a null vector. (0,0) More...
 
static Vector2 UnitX => new Vector2(1.0f, 0.0f)
 The X unit Vector2 (1, 0). More...
 
static Vector2 UnitY => new Vector2(0.0f, 1.0f)
 The Y unit Vector2 (0, 1). More...
 
static Vector2 Up => new Vector2(0.0f, 1.0f)
 Returns the up vector. (0,1) More...
 
static Vector2 Down => new Vector2(0.0f, -1.0f)
 Returns the down vector. (0,-1) More...
 
static Vector2 Right => new Vector2(1.0f, 0.0f)
 Returns the right vector. (1,0) More...
 
static Vector2 Left => new Vector2(-1.0f, 0.0f)
 Returns the left vector. (-1,0) More...
 

Properties

float this[int index] [get, set]
 Gets or sets the component at the specified index. More...
 

Constructor & Destructor Documentation

◆ Vector2()

GTA.Math.Vector2.Vector2 ( float  x,
float  y 
)

Initializes a new instance of the Vector2 class.

Parameters
xInitial value for the X component of the vector.
yInitial value for the Y component of the vector.

Member Function Documentation

◆ Add()

static Vector2 GTA.Math.Vector2.Add ( Vector2  left,
Vector2  right 
)
static

Adds two vectors.

Parameters
leftThe first vector to add.
rightThe second vector to add.
Returns
The sum of the two vectors.

◆ Angle()

static float GTA.Math.Vector2.Angle ( Vector2  from,
Vector2  to 
)
static

Returns the angle in degrees between from and to. The angle returned is always the acute angle between the two vectors.

◆ Clamp()

static Vector2 GTA.Math.Vector2.Clamp ( Vector2  value,
Vector2  min,
Vector2  max 
)
static

Restricts a value to be within a specified range.

Parameters
valueThe value to clamp.
minThe minimum value.
maxThe maximum value.
Returns
The clamped value.

◆ Distance()

static float GTA.Math.Vector2.Distance ( Vector2  position1,
Vector2  position2 
)
static

Calculates the distance between two vectors.

Parameters
position1The first vector to calculate the distance to the second vector.
position2The second vector to calculate the distance to the first vector.
Returns
The distance between the two vectors.

◆ DistanceSquared()

static float GTA.Math.Vector2.DistanceSquared ( Vector2  position1,
Vector2  position2 
)
static

Calculates the squared distance between two vectors.

Parameters
position1The first vector to calculate the squared distance to the second vector.
position2The second vector to calculate the squared distance to the first vector.
Returns
The squared distance between the two vectors.

◆ DistanceTo()

float GTA.Math.Vector2.DistanceTo ( Vector2  position)

Calculates the distance between two vectors.

Parameters
positionThe second vector to calculate the distance to.
Returns
The distance to the other vector.

◆ DistanceToSquared()

float GTA.Math.Vector2.DistanceToSquared ( Vector2  position)

Calculates the squared distance between two vectors.

Parameters
positionThe second vector to calculate the squared distance to.
Returns
The squared distance to the other vector.

◆ Divide()

static Vector2 GTA.Math.Vector2.Divide ( Vector2  value,
float  scale 
)
static

Scales a vector by the given value.

Parameters
valueThe vector to scale.
scaleThe amount by which to scale the vector.
Returns
The scaled vector.

◆ Dot()

static float GTA.Math.Vector2.Dot ( Vector2  left,
Vector2  right 
)
static

Calculates the dot product of two vectors.

Parameters
leftFirst source vector.
rightSecond source vector.
Returns
The dot product of the two vectors.

◆ Equals() [1/2]

override bool GTA.Math.Vector2.Equals ( object  obj)

Returns a value that indicates whether the current instance is equal to a specified object.

Parameters
objObject to make the comparison with.
Returns
true if the current instance is equal to the specified object; otherwise, false.

◆ Equals() [2/2]

bool GTA.Math.Vector2.Equals ( Vector2  other)

Returns a value that indicates whether the current instance is equal to the specified object.

Parameters
otherObject to make the comparison with.
Returns
true if the current instance is equal to the specified object; false otherwise.

◆ GetHashCode()

override int GTA.Math.Vector2.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

◆ Length()

float GTA.Math.Vector2.Length ( )

Calculates the length of the vector.

Returns
The length of the vector.

◆ LengthSquared()

float GTA.Math.Vector2.LengthSquared ( )

Calculates the squared length of the vector.

Returns
The squared length of the vector.

◆ Lerp()

static Vector2 GTA.Math.Vector2.Lerp ( Vector2  start,
Vector2  end,
float  amount 
)
static

Performs a linear interpolation between two vectors.

Parameters
startStart vector.
endEnd vector.
amountValue between 0 and 1 indicating the weight of end .
Returns
The linear interpolation of the two vectors.

This method performs the linear interpolation based on the following formula.

start + (end - start) * amount

Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

◆ Maximize()

static Vector2 GTA.Math.Vector2.Maximize ( Vector2  left,
Vector2  right 
)
static

Returns a vector containing the largest components of the specified vectors.

Parameters
leftThe first source vector.
rightThe second source vector.
Returns
A vector containing the largest components of the source vectors.

◆ Minimize()

static Vector2 GTA.Math.Vector2.Minimize ( Vector2  left,
Vector2  right 
)
static

Returns a vector containing the smallest components of the specified vectors.

Parameters
leftThe first source vector.
rightThe second source vector.
Returns
A vector containing the smallest components of the source vectors.

◆ Multiply() [1/2]

static Vector2 GTA.Math.Vector2.Multiply ( Vector2  left,
Vector2  right 
)
static

Multiplies a vector with another by performing component-wise multiplication.

Parameters
leftThe first vector to multiply.
rightThe second vector to multiply.
Returns
The multiplied vector.

◆ Multiply() [2/2]

static Vector2 GTA.Math.Vector2.Multiply ( Vector2  value,
float  scale 
)
static

Scales a vector by the given value.

Parameters
valueThe vector to scale.
scaleThe amount by which to scale the vector.
Returns
The scaled vector.

◆ Negate()

static Vector2 GTA.Math.Vector2.Negate ( Vector2  value)
static

Reverses the direction of a given vector.

Parameters
valueThe vector to negate.
Returns
A vector facing in the opposite direction.

◆ Normalize() [1/2]

void GTA.Math.Vector2.Normalize ( )

Converts the vector into a unit vector.

◆ Normalize() [2/2]

static Vector2 GTA.Math.Vector2.Normalize ( Vector2  vector)
static

Converts the vector into a unit vector.

Parameters
vectorThe vector to normalize.
Returns
The normalized vector.

◆ operator Vector3()

static implicit GTA.Math.Vector2.operator Vector3 ( Vector2  vector)
static

Converts a Vector2 to a Vector3 implicitly.

◆ operator!=()

static bool GTA.Math.Vector2.operator!= ( Vector2  left,
Vector2  right 
)
static

Tests for inequality between two objects.

Parameters
leftThe first value to compare.
rightThe second value to compare.
Returns
true if left has a different value than right ; otherwise, false.

◆ operator*() [1/2]

static Vector2 GTA.Math.Vector2.operator* ( float  scale,
Vector2  vector 
)
static

Scales a vector by the given value.

Parameters
vectorThe vector to scale.
scaleThe amount by which to scale the vector.
Returns
The scaled vector.

◆ operator*() [2/2]

static Vector2 GTA.Math.Vector2.operator* ( Vector2  vector,
float  scale 
)
static

Scales a vector by the given value.

Parameters
vectorThe vector to scale.
scaleThe amount by which to scale the vector.
Returns
The scaled vector.

◆ operator+()

static Vector2 GTA.Math.Vector2.operator+ ( Vector2  left,
Vector2  right 
)
static

Adds two vectors.

Parameters
leftThe first vector to add.
rightThe second vector to add.
Returns
The sum of the two vectors.

◆ operator-() [1/2]

static Vector2 GTA.Math.Vector2.operator- ( Vector2  left,
Vector2  right 
)
static

Subtracts two vectors.

Parameters
leftThe first vector to subtract.
rightThe second vector to subtract.
Returns
The difference of the two vectors.

◆ operator-() [2/2]

static Vector2 GTA.Math.Vector2.operator- ( Vector2  value)
static

Reverses the direction of a given vector.

Parameters
valueThe vector to negate.
Returns
A vector facing in the opposite direction.

◆ operator/()

static Vector2 GTA.Math.Vector2.operator/ ( Vector2  vector,
float  scale 
)
static

Scales a vector by the given value.

Parameters
vectorThe vector to scale.
scaleThe amount by which to scale the vector.
Returns
The scaled vector.

◆ operator==()

static bool GTA.Math.Vector2.operator== ( Vector2  left,
Vector2  right 
)
static

Tests for equality between two objects.

Parameters
leftThe first value to compare.
rightThe second value to compare.
Returns
true if left has the same value as right ; otherwise, false.

◆ RandomXY()

static Vector2 GTA.Math.Vector2.RandomXY ( )
static

Returns a new normalized vector with random X and Y components.

◆ Reflect()

static Vector2 GTA.Math.Vector2.Reflect ( Vector2  vector,
Vector2  normal 
)
static

Returns the reflection of a vector off a surface that has the specified normal.

Parameters
vectorThe source vector.
normalNormal of the surface.
Returns
The reflected vector.

Reflect only gives the direction of a reflection off a surface, it does not determine whether the original vector was close enough to the surface to hit it.

◆ SignedAngle()

static float GTA.Math.Vector2.SignedAngle ( Vector2  from,
Vector2  to 
)
static

Returns the signed angle in degrees between from and to.

◆ Subtract()

static Vector2 GTA.Math.Vector2.Subtract ( Vector2  left,
Vector2  right 
)
static

Subtracts two vectors.

Parameters
leftThe first vector to subtract.
rightThe second vector to subtract.
Returns
The difference of the two vectors.

◆ ToHeading()

float GTA.Math.Vector2.ToHeading ( )

Converts a vector to a heading.

◆ ToString() [1/2]

override string GTA.Math.Vector2.ToString ( )

Converts the value of the object to its equivalent string representation.

Returns
The string representation of the value of this instance.

◆ ToString() [2/2]

string GTA.Math.Vector2.ToString ( string  format)

Converts the value of the object to its equivalent string representation.

Parameters
formatThe format.
Returns
The string representation of the value of this instance.

Member Data Documentation

◆ Down

Vector2 GTA.Math.Vector2.Down => new Vector2(0.0f, -1.0f)
static

Returns the down vector. (0,-1)

◆ Left

Vector2 GTA.Math.Vector2.Left => new Vector2(-1.0f, 0.0f)
static

Returns the left vector. (-1,0)

◆ Normalized

Vector2 GTA.Math.Vector2.Normalized => Normalize(new Vector2(X, Y))

Returns this vector with a magnitude of 1.

◆ Right

Vector2 GTA.Math.Vector2.Right => new Vector2(1.0f, 0.0f)
static

Returns the right vector. (1,0)

◆ UnitX

Vector2 GTA.Math.Vector2.UnitX => new Vector2(1.0f, 0.0f)
static

The X unit Vector2 (1, 0).

◆ UnitY

Vector2 GTA.Math.Vector2.UnitY => new Vector2(0.0f, 1.0f)
static

The Y unit Vector2 (0, 1).

◆ Up

Vector2 GTA.Math.Vector2.Up => new Vector2(0.0f, 1.0f)
static

Returns the up vector. (0,1)

◆ X

float GTA.Math.Vector2.X

Gets or sets the X component of the vector.

The X component of the vector.

◆ Y

float GTA.Math.Vector2.Y

Gets or sets the Y component of the vector.

The Y component of the vector.

◆ Zero

Vector2 GTA.Math.Vector2.Zero => new Vector2(0.0f, 0.0f)
static

Returns a null vector. (0,0)

Property Documentation

◆ this[int index]

float GTA.Math.Vector2.this[int index]
getset

Gets or sets the component at the specified index.

The value of the X or Y component, depending on the index.

Parameters
indexThe index of the component to access. Use 0 for the X component and 1 for the Y component.
Returns
The value of the component at the specified index.
Exceptions
System.ArgumentOutOfRangeExceptionThrown when the index is out of the range [0, 1].

The documentation for this struct was generated from the following file: