Type Vector
3-dimensional vectors.
Methods
| Add( vector ) | Adds the given argument vector's component values to the given vector, modifying in-place. |
| Angle() | Returns an Angle object representing the vector as a forward direction, using Vector( 0, 0, 1 ) as up. |
| AngleEx( up ) | Returns an Angle object representing the vector as a forward direction, using the given up direction. |
| Cross( vector ) | Returns the cross product of the two vectors as a new vector. |
| DistToSqr( vector ) | Returns the squared distance between the two vectors. |
| Distance( vector ) | Returns the distance between the two vectors. |
| Div( divisor ) | Divides the vector by the given argument value, modifying in-place. |
| Dot( vector ) | Returns the dot product of the two vectors. |
| GetNormalized() | Returns a new vector that has the same direction as the given vector, but with length equal to 1. |
| IsEqualTol( vector, tolerance ) | Returns whether the given vectors are equal, using the given tolerance value. |
| IsZero() | Returns true if the given vector has all components equal to 0. |
| Length() | Returns the length of the vector. |
| Length2D() | Returns the 2-dimensional length of the vector (ignoring the z component). |
| Length2DSqr() | Returns the squared 2-dimensional length of the vector (ignoring the z component). |
| LengthSqr() | Returns the squared length of the vector. |
| Mul( multiplier ) | Multiplies the given vector by the given number, vector (component-wise) or VMatrix, modifying in-place. |
| Normalize() | Normalises the given vector's length to equal 1, modifying in-place. |
| Rotate( angles ) | Rotates the given vector by the given angles, modifying in-place. |
| Set( vector ) | Sets the vector's component values to equal the given vector, modifying in-place. |
| SetUnpacked( x, y, z ) | Sets the vector's component values, modifying in-place. |
| Sub( vector ) | Subtracts the given argument vector, modifying in-place. |
| ToColor() | Converts the vector into a colour by multiplying each component by 255. |
| ToScreen() | Returns the position on the local player's screen that corresponds to this vector as a world position. |
| ToTable() | Returns the vector as an array of 3 elements. |
| Unpack() | Returns the component values of the vector. |
| WithinAABox( mins, maxs ) | Returns true if the given vector is within the axis-aligned bounding box defined by the given vector arguments. |
| Zero() | Sets all component values to 0, modifying in-place.. |
Methods
- Vector:Add( vector )
-
Adds the given argument vector's component values to the given vector, modifying in-place.
Environment:
SharedParameters:
-
(Vector) vector: The vector to add.
Return value:
(Vector)The modified vector. -
- Vector:Angle()
-
Returns an Angle object representing the vector as a forward direction, using Vector( 0, 0, 1 ) as up.
Environment:
Shared - Vector:AngleEx( up )
-
Returns an Angle object representing the vector as a forward direction, using the given up direction.
Environment:
SharedParameters:
-
(Vector) up: The up direction to use.
-
- Vector:Cross( vector )
-
Returns the cross product of the two vectors as a new vector.
Environment:
SharedParameters:
-
(Vector) vector: The vector to take the cross product with.
-
- Vector:DistToSqr( vector )
-
Returns the squared distance between the two vectors. This avoids the cost of a square-root.
Environment:
SharedParameters:
-
(Vector) vector: The vector to get the squared distance from.
-
- Vector:Distance( vector )
-
Returns the distance between the two vectors.
Environment:
SharedParameters:
-
(Vector) vector: The vector to get the distance from.
-
- Vector:Div( divisor )
-
Divides the vector by the given argument value, modifying in-place.
Environment:
SharedParameters:
-
(number | Vector) divisor: The number or vector to divide the vector's components by.
Return value:
(Vector)The modified vector. -
- Vector:Dot( vector )
-
Returns the dot product of the two vectors.
Environment:
SharedParameters:
-
(Vector) vector: The vector to get the dot product with.
-
- Vector:GetNormalized()
-
Returns a new vector that has the same direction as the given vector, but with length equal to 1.
Environment:
Shared - Vector:IsEqualTol( vector, tolerance )
-
Returns whether the given vectors are equal, using the given tolerance value.
Environment:
SharedParameters:
-
(Vector) vector: The vector to compare against. -
(number) tolerance: The tolerance value to use to consider the vectors equal.
-
- Vector:IsZero()
-
Returns true if the given vector has all components equal to 0.
Environment:
Shared - Vector:Length()
-
Returns the length of the vector.
Environment:
Shared - Vector:Length2D()
-
Returns the 2-dimensional length of the vector (ignoring the z component).
Environment:
Shared - Vector:Length2DSqr()
-
Returns the squared 2-dimensional length of the vector (ignoring the z component).
Environment:
Shared - Vector:LengthSqr()
-
Returns the squared length of the vector.
Environment:
Shared - Vector:Mul( multiplier )
-
Multiplies the given vector by the given number, vector (component-wise) or VMatrix, modifying in-place.
Environment:
SharedParameters:
-
(number | Vector | VMatrix) multiplier: The value to multiply the vector's components with.
Return value:
(Vector)The modified vector. -
- Vector:Normalize()
-
Normalises the given vector's length to equal 1, modifying in-place.
Environment:
SharedReturn value:
(Vector)The normalised vector. - Vector:Rotate( angles )
-
Rotates the given vector by the given angles, modifying in-place.
Environment:
SharedParameters:
-
(Angle) angles: The angles to rotate the vector with.
Return value:
-
The rotated vector.
-
- Vector:Set( vector )
-
Sets the vector's component values to equal the given vector, modifying in-place.
Environment:
SharedParameters:
-
(Vector) vector: The vector to take the component values from.
Return value:
(Vector)The modified vector. -
- Vector:SetUnpacked( x, y, z )
-
Sets the vector's component values, modifying in-place.
Environment:
SharedParameters:
-
(number) x: The x-component value. -
(number) y: The y-component value. -
(number) z: The z-component value.
Return value:
(Vector)The modified vector. -
- Vector:Sub( vector )
-
Subtracts the given argument vector, modifying in-place.
Environment:
SharedParameters:
-
(Vector) vector: The vector to subtract.
Return value:
(Vector)The modified vector. -
- Vector:ToColor()
-
Converts the vector into a colour by multiplying each component by 255.
Environment:
SharedReturn value:
(Color)A colour representing the vector. - Vector:ToScreen()
-
Returns the position on the local player's screen that corresponds to this vector as a world position.
Environment:
Client - Vector:ToTable()
-
Returns the vector as an array of 3 elements.
Environment:
Shared - Vector:Unpack()
-
Returns the component values of the vector.
Environment:
SharedReturn values:
-
(number)The x-component. -
(number)The y-component. -
(number)The z-component.
-
- Vector:WithinAABox( mins, maxs )
-
Returns true if the given vector is within the axis-aligned bounding box defined by the given vector arguments.
Environment:
SharedParameters:
-
(Vector) mins: The minimum corner of the box. -
(Vector) maxs: The maximum corner of the box.
-
- Vector:Zero()
-
Sets all component values to 0, modifying in-place..
Environment:
SharedReturn value:
(Vector)The modified vector.