List of all possible functions to manipulate vectors.
Created by Vector.
|number||x or 1||The X component of the vector.|
|number||y or 2||The Y component of the vector.|
|number||z or 3||The Z component of the vector.|
Vector:Add( Vector vector )
Adds the values of the argument vector to the orignal vector. This functions 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 the vector, 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 pythagorean distance between the vector and the other vector. This is a relatively expensive process since it uses the square root. It is recommended that you use Vector:DistToSqr whenever possible.
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.
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 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.
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 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.
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.cam.Start3D or 3D context cam.Start with non-default parameters incorrectly sets the reference FOV for this function, causing incorrect return values. This..
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.