SVec3
A 3-element structure that can be used to represent positions and directions in 3D-space.
Constructors
Method New(x:Float, y:Float, z:Float)
Creates a new SVec3 from the supplied arguments.
Operators
Method Operator+:SVec3(b:SVec3)
Adds b to this vector, returning a new vector.
Method Operator-:SVec3(b:SVec3)
Subtracts b from this vector, returning a new vector.
Method Operator*:SVec3(b:SVec3)
Multiplies the vector by b, returning a new vector.
Method Operator/:SVec3(b:SVec3)
Devides the vector by b, returning a new vector.
Method Operator-:SVec3()
Returns a negated version of this vector.
Method Operator*:SVec3(s:Float)
Multiplies the vector by s, returning the new vector.
Method Operator[]:Float(index:Int)
Retrieves the x, y or z component using [0], [1] or [2] respectively.
Method Operator[]=(index:Int, value:Float)
Sets the x, y or z component using [0], [1] or [2] respectively.
Methods
Method Apply:SVec3(b:SMat3 Var)
Applies the 3x3 matrix b to the vector, returning a new vector.
Method Apply:SVec3(b:SMat4 Var)
Applies the 4x4 metrix b to the vector, returning a new vector.
Method Clamp:SVec3(minv:SVec3, maxv:SVec3)
Returns the vector clamped between the vectors minv and maxv.
Method Cross:SVec3(b:SVec3)
Returns the Cross Product of the two vectors.
Method Min:SVec3(b:SVec3)
Returns a vector that is made from the smallest components of the two vectors.
Method Max:SVec3(b:SVec3)
Returns a vector that is made from the largest components of the two vectors.
Method Lerp:SVec3(b:SVec3, t:Float)
Linearly interpolates between two vectors.
Interpolates between this vector and b by the interpolant t. This is commonly used to find a point some fraction of the way along a line between two endpoints (e.g. to move an object gradually between those points).
Method Normal:SVec3()
Returns the vector with a magnitude of 1.
When normalized, a vector keeps the same direction but its length is 1.0.
Method Dot:Float(b:SVec3)
Returns the dot product of two vectors.
For normalized vectors Dot returns 1 if they point in exactly the same direction, -1 if they point in completely opposite directions, and a number in between for other cases (e.g. Dot returns zero if vectors are perpendicular).
Method Length:Float()
Returns the length of the vector.
Method LengthSquared:Float()
Returns the squared length of the vector.
Calculating the squared length instead of the length is much faster. Often if you are comparing lengths of two vectors you can just compare their squared lengths.
Method Distance:Float(b:SVec3)
Returns the distance between the vector and b.
Method DistanceSquared:Float(b:SVec3)
Returns the squared distance between the vector and b.
Method Reflect:SVec3(n:SVec3)
Returns the vector reflected from the given plane, specified by its normal vector.
Method ToString:String() Override
Returns a String representation of the vector.