Class Vector
- Namespace
- CounterStrikeSharp.API.Modules.Utils
- Assembly
- CounterStrikeSharp.API.dll
A Vector
object represents a line with a direction and length.
Each vector contains three co-ordinates:
- X+forward/-backward
- Y+left/-right
- Z+up/-down
public class Vector : NativeObject
- Inheritance
-
Vector
- Inherited Members
Constructors
Vector(nint)
public Vector(nint pointer)
Parameters
pointer
nint
Vector(float?, float?, float?)
public Vector(float? x = null, float? y = null, float? z = null)
Parameters
Properties
this[int]
public float this[int i] { get; set; }
Parameters
i
int
Property Value
X
public ref float X { get; }
Property Value
Y
public ref float Y { get; }
Property Value
Z
public ref float Z { get; }
Property Value
Methods
Add(Vector)
Adds values of argument vector to the original vector. Does not create a new vector object, skipping object construction.
public void Add(Vector vector)
Parameters
vector
Vector
Angle()
Returns an angle that represents the normal of the vector.
public Angle Angle()
Returns
Angle(Vector)
Returns the angle of the vector, but allows the use of a different 'up' direction.
public Angle Angle(Vector up)
Parameters
up
VectorDirection for up
Returns
IsZero()
Returns whether all fields on the Vector are 0.
public bool IsZero()
Returns
Length()
Returns the Euclidean length of the vector: √x² + y² + z²
public float Length()
Returns
- float
Euclidean length of vector
Length2D()
Returns length of Vector excluding Z axis.
public float Length2D()
Returns
- float
2D Length
Length2DSqr()
Returns the squared length of the vectors x and y value, x² + y². Faster than Length2D()
public float Length2DSqr()
Returns
LengthSqr()
Returns the squared length of the vector, x² + y² + z². Faster than Length()
public float LengthSqr()
Returns
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
With(float?, float?, float?)
Returns a copy of the vector with values replaced.
public Vector With(float? x = null, float? y = null, float? z = null)
Parameters
Returns
- Vector
Copy of vector
Operators
operator +(Vector, Vector)
public static Vector operator +(Vector a, Vector b)
Parameters
Returns
operator /(Vector, float)
public static Vector operator /(Vector a, float b)
Parameters
Returns
operator *(Vector, float)
public static Vector operator *(Vector a, float b)
Parameters
Returns
operator -(Vector, Vector)
public static Vector operator -(Vector a, Vector b)
Parameters
Returns
operator -(Vector)
public static Vector operator -(Vector a)
Parameters
a
Vector