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.Vector3 Struct Reference
Inheritance diagram for GTA.Math.Vector3:

Public Member Functions

 Vector3 (float x, float y, float z)
 Initializes a new instance of the Vector3 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 (Vector3 position)
 Calculates the distance between two vectors. More...
 
float DistanceToSquared (Vector3 position)
 Calculates the squared distance between two vectors. More...
 
float DistanceTo2D (Vector3 position)
 Calculates the distance between two vectors, ignoring the Z-component. More...
 
float DistanceToSquared2D (Vector3 position)
 Calculates the squared distance between two vectors, ignoring the Z-component. More...
 
float ToHeading ()
 Converts a vector to a heading. More...
 
Vector3 Around (float distance)
 Creates a random vector inside the circle around this position. More...
 
Vector3 Round (int decimalPlaces=2)
 Rounds each float inside the vector to a select amount of decimal places (2 by default). More...
 
float[] ToArray ()
 Converts the matrix to an array of floats. 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 (Vector3 other)
 Returns a value that indicates whether the current instance is equal to the specified object. More...
 

Static Public Member Functions

static float Distance (Vector3 position1, Vector3 position2)
 Calculates the distance between two vectors. More...
 
static float DistanceSquared (Vector3 position1, Vector3 position2)
 Calculates the squared distance between two vectors. More...
 
static float Distance2D (Vector3 position1, Vector3 position2)
 Calculates the distance between two vectors, ignoring the Z-component. More...
 
static float DistanceSquared2D (Vector3 position1, Vector3 position2)
 Calculates the squared distance between two vectors, ignoring the Z-component. More...
 
static float Angle (Vector3 from, Vector3 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 (Vector3 from, Vector3 to, Vector3 planeNormal)
 Returns the signed angle in degrees between from and to. More...
 
static Vector3 RandomXY ()
 Returns a new normalized vector with random X and Y components. More...
 
static Vector3 RandomXYZ ()
 Returns a new normalized vector with random X, Y and Z components. More...
 
static Vector3 Add (Vector3 left, Vector3 right)
 Adds two vectors. More...
 
static Vector3 Subtract (Vector3 left, Vector3 right)
 Subtracts two vectors. More...
 
static Vector3 Multiply (Vector3 value, float scale)
 Scales a vector by the given value. More...
 
static Vector3 Multiply (Vector3 left, Vector3 right)
 Multiply a vector with another by performing component-wise multiplication. More...
 
static Vector3 Divide (Vector3 value, float scale)
 Scales a vector by the given value. More...
 
static Vector3 Negate (Vector3 value)
 Reverses the direction of a given vector. More...
 
static Vector3 Clamp (Vector3 value, Vector3 min, Vector3 max)
 Restricts a value to be within a specified range. More...
 
static Vector3 Lerp (Vector3 start, Vector3 end, float amount)
 Performs a linear interpolation between two vectors. More...
 
static Vector3 Normalize (Vector3 vector)
 Converts the vector into a unit vector. More...
 
static float Dot (Vector3 left, Vector3 right)
 Calculates the dot product of two vectors. More...
 
static Vector3 Cross (Vector3 left, Vector3 right)
 Calculates the cross product of two vectors. More...
 
static Vector3 Project (Vector3 vector, Vector3 onNormal)
 Projects a vector onto another vector. More...
 
static Vector3 ProjectOnPlane (Vector3 vector, Vector3 planeNormal)
 Projects a vector onto a plane defined by a normal orthogonal to the plane. More...
 
static Vector3 Reflect (Vector3 vector, Vector3 normal)
 Returns the reflection of a vector off a surface that has the specified normal. More...
 
static Vector3 Minimize (Vector3 left, Vector3 right)
 Returns a vector containing the smallest components of the specified vectors. More...
 
static Vector3 Maximize (Vector3 left, Vector3 right)
 Returns a vector containing the largest components of the specified vectors. More...
 
static Vector3 operator+ (Vector3 left, Vector3 right)
 Adds two vectors. More...
 
static Vector3 operator- (Vector3 left, Vector3 right)
 Subtracts two vectors. More...
 
static Vector3 operator- (Vector3 vector)
 Reverses the direction of a given vector. More...
 
static Vector3 operator* (Vector3 vector, float scale)
 Scales a vector by the given value. More...
 
static Vector3 operator* (float scale, Vector3 vector)
 Scales a vector by the given value. More...
 
static Vector3 operator/ (Vector3 vector, float scale)
 Scales a vector by the given value. More...
 
static bool operator== (Vector3 left, Vector3 right)
 Tests for equality between two objects. More...
 
static bool operator!= (Vector3 left, Vector3 right)
 Tests for inequality between two objects. More...
 
static implicit operator Vector2 (Vector3 vector)
 Converts a Vector3 to a Vector2 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...
 
float Z
 Gets or sets the Z component of the vector. More...
 
float _padding
 
Vector3 Normalized => Normalize(new Vector3(X, Y, Z))
 Returns this vector with a magnitude of 1. More...
 

Static Public Attributes

static Vector3 Zero => new Vector3(0.0f, 0.0f, 0.0f)
 Returns a null vector. (0,0,0) More...
 
static Vector3 UnitX => new Vector3(1.0f, 0.0f, 0.0f)
 The X unit Vector3 (1, 0, 0). More...
 
static Vector3 UnitY => new Vector3(0.0f, 1.0f, 0.0f)
 The Y unit Vector3 (0, 1, 0). More...
 
static Vector3 UnitZ => new Vector3(0.0f, 0.0f, 1.0f)
 The Z unit Vector3 (0, 0, 1). More...
 
static Vector3 WorldUp => new Vector3(0.0f, 0.0f, 1.0f)
 Returns the world Up vector. (0,0,1) More...
 
static Vector3 WorldDown => new Vector3(0.0f, 0.0f, -1.0f)
 Returns the world Down vector. (0,0,-1) More...
 
static Vector3 WorldNorth => new Vector3(0.0f, 1.0f, 0.0f)
 Returns the world North vector. (0,1,0) More...
 
static Vector3 WorldSouth => new Vector3(0.0f, -1.0f, 0.0f)
 Returns the world South vector. (0,-1,0) More...
 
static Vector3 WorldEast => new Vector3(1.0f, 0.0f, 0.0f)
 Returns the world East vector. (1,0,0) More...
 
static Vector3 WorldWest => new Vector3(-1.0f, 0.0f, 0.0f)
 Returns the world West vector. (-1,0,0) More...
 
static Vector3 RelativeRight => new Vector3(1.0f, 0.0f, 0.0f)
 Returns the relative Right vector. (1,0,0) More...
 
static Vector3 RelativeLeft => new Vector3(-1.0f, 0.0f, 0.0f)
 Returns the relative Left vector. (-1,0,0) More...
 
static Vector3 RelativeFront => new Vector3(0.0f, 1.0f, 0.0f)
 Returns the relative Front vector. (0,1,0) More...
 
static Vector3 RelativeBack => new Vector3(0.0f, -1.0f, 0.0f)
 Returns the relative Back vector. (0,-1,0) More...
 
static Vector3 RelativeTop => new Vector3(0.0f, 0.0f, 1.0f)
 Returns the relative Top vector. (0,0,1) More...
 
static Vector3 RelativeBottom => new Vector3(0.0f, 0.0f, -1.0f)
 Returns the relative Bottom vector as used. (0,0,-1) More...
 

Properties

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

Constructor & Destructor Documentation

◆ Vector3()

GTA.Math.Vector3.Vector3 ( float  x,
float  y,
float  z 
)

Initializes a new instance of the Vector3 class.

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

Member Function Documentation

◆ Add()

static Vector3 GTA.Math.Vector3.Add ( Vector3  left,
Vector3  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.Vector3.Angle ( Vector3  from,
Vector3  to 
)
static

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

◆ Around()

Vector3 GTA.Math.Vector3.Around ( float  distance)

Creates a random vector inside the circle around this position.

◆ Clamp()

static Vector3 GTA.Math.Vector3.Clamp ( Vector3  value,
Vector3  min,
Vector3  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.

◆ Cross()

static Vector3 GTA.Math.Vector3.Cross ( Vector3  left,
Vector3  right 
)
static

Calculates the cross product of two vectors.

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

◆ Distance()

static float GTA.Math.Vector3.Distance ( Vector3  position1,
Vector3  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.

◆ Distance2D()

static float GTA.Math.Vector3.Distance2D ( Vector3  position1,
Vector3  position2 
)
static

Calculates the distance between two vectors, ignoring the Z-component.

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.Vector3.DistanceSquared ( Vector3  position1,
Vector3  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.

◆ DistanceSquared2D()

static float GTA.Math.Vector3.DistanceSquared2D ( Vector3  position1,
Vector3  position2 
)
static

Calculates the squared distance between two vectors, ignoring the Z-component.

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.Vector3.DistanceTo ( Vector3  position)

Calculates the distance between two vectors.

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

◆ DistanceTo2D()

float GTA.Math.Vector3.DistanceTo2D ( Vector3  position)

Calculates the distance between two vectors, ignoring the Z-component.

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

◆ DistanceToSquared()

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

Calculates the squared distance between two vectors.

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

◆ DistanceToSquared2D()

float GTA.Math.Vector3.DistanceToSquared2D ( Vector3  position)

Calculates the squared distance between two vectors, ignoring the Z-component.

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

◆ Divide()

static Vector3 GTA.Math.Vector3.Divide ( Vector3  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.Vector3.Dot ( Vector3  left,
Vector3  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.Vector3.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; false otherwise.

◆ Equals() [2/2]

bool GTA.Math.Vector3.Equals ( Vector3  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.Vector3.GetHashCode ( )

Returns the hash code for this instance.

Returns
A 32-bit signed integer hash code.

◆ Length()

float GTA.Math.Vector3.Length ( )

Calculates the length of the vector.

Returns
The length of the vector.

◆ LengthSquared()

float GTA.Math.Vector3.LengthSquared ( )

Calculates the squared length of the vector.

Returns
The squared length of the vector.

◆ Lerp()

static Vector3 GTA.Math.Vector3.Lerp ( Vector3  start,
Vector3  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 Vector3 GTA.Math.Vector3.Maximize ( Vector3  left,
Vector3  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 Vector3 GTA.Math.Vector3.Minimize ( Vector3  left,
Vector3  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 Vector3 GTA.Math.Vector3.Multiply ( Vector3  left,
Vector3  right 
)
static

Multiply 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 Vector3 GTA.Math.Vector3.Multiply ( Vector3  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 Vector3 GTA.Math.Vector3.Negate ( Vector3  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.Vector3.Normalize ( )

Converts the vector into a unit vector.

◆ Normalize() [2/2]

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

Converts the vector into a unit vector.

Parameters
vectorThe vector to normalize.
Returns
The normalized vector.

◆ operator Vector2()

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

Converts a Vector3 to a Vector2 implicitly.

◆ operator!=()

static bool GTA.Math.Vector3.operator!= ( Vector3  left,
Vector3  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 Vector3 GTA.Math.Vector3.operator* ( float  scale,
Vector3  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 Vector3 GTA.Math.Vector3.operator* ( Vector3  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 Vector3 GTA.Math.Vector3.operator+ ( Vector3  left,
Vector3  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 Vector3 GTA.Math.Vector3.operator- ( Vector3  left,
Vector3  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 Vector3 GTA.Math.Vector3.operator- ( Vector3  vector)
static

Reverses the direction of a given vector.

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

◆ operator/()

static Vector3 GTA.Math.Vector3.operator/ ( Vector3  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.Vector3.operator== ( Vector3  left,
Vector3  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.

◆ Project()

static Vector3 GTA.Math.Vector3.Project ( Vector3  vector,
Vector3  onNormal 
)
static

Projects a vector onto another vector.

Parameters
vectorThe vector to project.
onNormalVector to project onto, does not assume it is normalized.
Returns
The projected vector.

◆ ProjectOnPlane()

static Vector3 GTA.Math.Vector3.ProjectOnPlane ( Vector3  vector,
Vector3  planeNormal 
)
static

Projects a vector onto a plane defined by a normal orthogonal to the plane.

Parameters
vectorThe vector to project.
planeNormalNormal of the plane, does not assume it is normalized.
Returns
The Projection of vector onto plane.

◆ RandomXY()

static Vector3 GTA.Math.Vector3.RandomXY ( )
static

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

◆ RandomXYZ()

static Vector3 GTA.Math.Vector3.RandomXYZ ( )
static

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

◆ Reflect()

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

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

Parameters
vectorThe vector to project onto the plane.
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.

◆ Round()

Vector3 GTA.Math.Vector3.Round ( int  decimalPlaces = 2)

Rounds each float inside the vector to a select amount of decimal places (2 by default).

Parameters
decimalPlacesNumber of decimal places to round to
Returns
The vector containing rounded values

◆ SignedAngle()

static float GTA.Math.Vector3.SignedAngle ( Vector3  from,
Vector3  to,
Vector3  planeNormal 
)
static

Returns the signed angle in degrees between from and to.

◆ Subtract()

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

Subtracts two vectors.

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

◆ ToArray()

float [] GTA.Math.Vector3.ToArray ( )

Converts the matrix to an array of floats.

◆ ToHeading()

float GTA.Math.Vector3.ToHeading ( )

Converts a vector to a heading.

◆ ToString() [1/2]

override string GTA.Math.Vector3.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.Vector3.ToString ( string  format)

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

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

Member Data Documentation

◆ _padding

float GTA.Math.Vector3._padding

◆ Normalized

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

Returns this vector with a magnitude of 1.

◆ RelativeBack

Vector3 GTA.Math.Vector3.RelativeBack => new Vector3(0.0f, -1.0f, 0.0f)
static

Returns the relative Back vector. (0,-1,0)

◆ RelativeBottom

Vector3 GTA.Math.Vector3.RelativeBottom => new Vector3(0.0f, 0.0f, -1.0f)
static

Returns the relative Bottom vector as used. (0,0,-1)

◆ RelativeFront

Vector3 GTA.Math.Vector3.RelativeFront => new Vector3(0.0f, 1.0f, 0.0f)
static

Returns the relative Front vector. (0,1,0)

◆ RelativeLeft

Vector3 GTA.Math.Vector3.RelativeLeft => new Vector3(-1.0f, 0.0f, 0.0f)
static

Returns the relative Left vector. (-1,0,0)

◆ RelativeRight

Vector3 GTA.Math.Vector3.RelativeRight => new Vector3(1.0f, 0.0f, 0.0f)
static

Returns the relative Right vector. (1,0,0)

◆ RelativeTop

Vector3 GTA.Math.Vector3.RelativeTop => new Vector3(0.0f, 0.0f, 1.0f)
static

Returns the relative Top vector. (0,0,1)

◆ UnitX

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

The X unit Vector3 (1, 0, 0).

◆ UnitY

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

The Y unit Vector3 (0, 1, 0).

◆ UnitZ

Vector3 GTA.Math.Vector3.UnitZ => new Vector3(0.0f, 0.0f, 1.0f)
static

The Z unit Vector3 (0, 0, 1).

◆ WorldDown

Vector3 GTA.Math.Vector3.WorldDown => new Vector3(0.0f, 0.0f, -1.0f)
static

Returns the world Down vector. (0,0,-1)

◆ WorldEast

Vector3 GTA.Math.Vector3.WorldEast => new Vector3(1.0f, 0.0f, 0.0f)
static

Returns the world East vector. (1,0,0)

◆ WorldNorth

Vector3 GTA.Math.Vector3.WorldNorth => new Vector3(0.0f, 1.0f, 0.0f)
static

Returns the world North vector. (0,1,0)

◆ WorldSouth

Vector3 GTA.Math.Vector3.WorldSouth => new Vector3(0.0f, -1.0f, 0.0f)
static

Returns the world South vector. (0,-1,0)

◆ WorldUp

Vector3 GTA.Math.Vector3.WorldUp => new Vector3(0.0f, 0.0f, 1.0f)
static

Returns the world Up vector. (0,0,1)

◆ WorldWest

Vector3 GTA.Math.Vector3.WorldWest => new Vector3(-1.0f, 0.0f, 0.0f)
static

Returns the world West vector. (-1,0,0)

◆ X

float GTA.Math.Vector3.X

Gets or sets the X component of the vector.

The X component of the vector.

◆ Y

float GTA.Math.Vector3.Y

Gets or sets the Y component of the vector.

The Y component of the vector.

◆ Z

float GTA.Math.Vector3.Z

Gets or sets the Z component of the vector.

The Z component of the vector.

◆ Zero

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

Returns a null vector. (0,0,0)

Property Documentation

◆ this[int index]

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

Gets or sets the component at the specified index.

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

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

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