List of all possible functions to manipulate vectors.
Created by Vector.
||The X component of the vector.|
||The Y component of the vector.|
||The Z component of the vector.|
||Vector||Returns new Vector with the result of addition.|
||number||Returns new Vector with the result of division.|
||any||Compares 2 operands, if they both are Vector, compares each individual component.|
||number or string||Gets the component of the Vector. Returns a number.|
||number or Vector||Returns new Vector with the result of multiplication.|
||number or string||Sets the component of the Vector. Accepts number and string.|
||Vector||Returns new Vector with the result of subtraction.|
||Returns new Vector with the result of negation.|
Vector:Add( Vector vector )
Adds the values of the argument vector to the original vector. This function is the same as vector1 + vector2 without creating a new vector object, skipping object construction and garbage collection.
Angle Vector:AngleEx( Vector up )
Returns the angle of this vector (normalized), but instead of assuming that up is Vector( 0, 0, 1 ) (Like Vector:Angle does) you can specify which direction is 'up' for the angle.
Vector Vector:Cross( Vector otherVector )
Calculates the cross product of this vector and the passed one. The cross product of two vectors is a 3-dimensional vector with a direction perpendicular (at right angles) to both of them (according to the right-hand rule), and magnitude equal to the area of parallelogram they span. This is defined as the product of the magnitudes, the sine of the angle between them, and unit (normal) vector n defined by the right-hand rule: :a × b = |a| |b| sin(θ) n̂ where a and b are vectors, and n̂ is a unit vector (ma..
number Vector:Distance( Vector otherVector )
Returns the euclidean distance between the vector and the other vector. This function is more expensive than Vector:DistToSqr. However, please see the notes for Vector:DistToSqr before using it as squared distances are not the same as euclidean distances.
number Vector:DistToSqr( Vector otherVec )
Returns the squared distance of 2 vectors, this is faster than Vector:Distance as calculating the square root is an expensive process. Squared distances should not be summed. If you need to sum distances, use Vector:Distance. When performing a distance check, ensure the distance being checked against is squared. See example code below.
Vector:Div( number divisor )
Divide the vector by the given number, that means x, y and z are divided by that value. This will change the value of the original vector, see example 2 for division without changing the value.
number Vector:Dot( Vector otherVector )
Returns the dot product of this vector and the passed one. The dot product of two vectors is the product of their magnitudes (lengths), and the cosine of the angle between them: a · b = |a| |b| cos(θ) where a and b are vectors. See Vector:Length for obtaining magnitudes. A dot product returns just the cosine of the angle if both vectors are normalized, and zero if the vectors are at right angles to each other.
number Vector:DotProduct( Vector Vector )
We advise against using this. It may be changed or removed in a future update. This is an alias of Vector:Dot. Use that instead. Returns the dot product of the two vectors.
Returns the negative version of this vector, i. e. a vector with every component to the negative value of itself. See also Vector:Negate.
We advise against using this. It may be changed or removed in a future update. Use Vector:GetNormalized instead. Returns a normalized version of the vector. This is a alias of Vector:GetNormalized.
Returns a normalized version of the vector. Normalized means vector with same direction but with length of 1. This does not affect the vector you call it on; to do this, use Vector:Normalize.
boolean Vector:IsEqualTol( Vector compare, number tolerance )
Returns if the vector is equal to another vector with the given tolerance.
Returns the Euclidean length of the vector: √(x² + y² + z²). This is a relatively expensive process since it uses the square root. It is recommended that you use Vector:LengthSqr whenever possible.
Returns the length of the vector in two dimensions, without the Z axis. This is a relatively expensive process since it uses the square root. It is recommended that you use Vector:Length2DSqr whenever possible.
Returns the squared length of the vectors x and y value, x² + y². This is faster than Vector:Length2D as calculating the square root is an expensive process.
Returns the squared length of the vector, x² + y² + z². This is faster than Vector:Length as calculating the square root is an expensive process.
Vector:Mul( number multiplier )
Scales the vector by the given number (that means x, y and z are multiplied by that value) or Vector.
Negates this vector, i. e. sets every component to the negative value of itself. Same as Vector( -vec. x, -vec. y, -vec. z )
Normalizes the given vector. This changes the vector you call it on, if you want to return a normalized copy without affecting the original, use Vector:GetNormalized.
Vector:Rotate( Angle rotation )
Rotates a vector by the given angle. Doesn't return anything, but rather changes the original vector.
Vector:Sub( Vector vector )
Substracts the values of the second vector from the orignal vector, this function can be used to avoid garbage collection.
Translates the Vector (values ranging from 0 to 1) into a Color. This will also range the values from 0 - 1 to 0 - 255. x * 255 -> r y * 255 -> g z * 255 -> b This is the opposite of Color:ToVector
Returns where on the screen the specified position vector would appear. A related function is gui.ScreenToVector, which converts a 2D coordinate to a 3D direction. Should be called from a 3D rendering environment or after cam.Start3D or it may not work correctly.Errors in a render hook can make this value incorrect until the player restarts their game.Issue Tracker: 462cam.Start3D or 3D context cam.Start with non-default parameters incorrectly sets the reference FOV for this function, causing incorrect re..
boolean Vector:WithinAABox( Vector boxStart, Vector boxEnd )
Returns whenever the given vector is in a box created by the 2 other vectors.
Sets x, y and z to 0.