Skyline Lua API
Version 1.0
Lua Script Reference for Skyline Game Engine.

#include <LUA_API_Vector3.h>
Public Member Functions  
float  dotProduct (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Calculates the dot (scalar) product of this vector with another. More...  
float  absDotProduct (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Calculates the absolute dot (scalar) product of this vector with another. More...  
float  angle (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Gets the angle between 2 vectors. More...  
float3  crossProduct (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Calculates the crossproduct of 2 vectors, i.e. vector that lies perpendicular to them both. More...  
int  directionEquals (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z, float tolerance) 
Returns whether this vector is within a directional tolerance of another vector. More...  
float  distance (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Returns the distance to another vector. More...  
float4  getRotationTo (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z, float fallbackVec_X, float fallbackVec_Y, float fallbackVec_Z) 
Gets the shortest arc quaternion to rotate this vector to the destination vector. More...  
float3  midPoint (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Returns a vector at a point half way between this and the passed in vector. More...  
float  normalise (float vec1_X, float vec1_Y, float vec1_Z) 
Normalises the vector. More...  
float3  normalisedCopy (float vec1_X, float vec1_Y, float vec1_Z) 
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy. More...  
float  length (float vec1_X, float vec1_Y, float vec1_Z) 
Returns the length (magnitude) of the vector. More...  
int  isNAN (float vec1_X, float vec1_Y, float vec1_Z) 
Check whether this vector contains valid values. More...  
int  isZeroLength (float vec1_X, float vec1_Y, float vec1_Z) 
Returns true if this vector is zero length. More...  
float3  perpendicular (float vec1_X, float vec1_Y, float vec1_Z) 
Generates a vector perpendicular to this vector (eg an 'up' vector). More...  
int  positionCloses (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z, float tolerance) 
Returns whether this vector is within a positional tolerance of another vector, also take scale of the vectors into account. More...  
int  positionEquals (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z, float tolerance) 
Returns whether this vector is within a positional tolerance of another vector. More...  
float3  primaryAxis (float vec1_X, float vec1_Y, float vec1_Z) 
Extract the primary (dominant) axis from this direction vector. More...  
float3  randomDeviant (float vec1_X, float vec1_Y, float vec1_Z, float randomAngle, float vec2_X, float vec2_Y, float vec2_Z) 
Generates a new random vector which deviates from this vector by a given angle in a random direction. More...  
float3  reflect (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Calculates a reflection vector to the plane with the given normal . More...  
float  squaredDistance (float vec1_X, float vec1_Y, float vec1_Z, float vec2_X, float vec2_Y, float vec2_Z) 
Returns the square of the distance to another vector. More...  
float  squaredLength (float vec1_X, float vec1_Y, float vec1_Z) 
Returns the square of the length(magnitude) of the vector. More...  
This area covers vector3 functions. Use as vector3.function(); This is a utility class that gives you access to many easy functions for vector mathmatics. For more information on how these functions can be used please visit the User Manual  https://home.aurasoftskyline.co.uk
Example Cross Product of 2 vectors:
Lua = crossProduct = newType.vec3( vector3.crossProduct(vec1X, vec1Y, vec1Z, vec2X, vec2Y, vec2Z ) );
this is essentially doing :
c++ = Vector3 return = vec1.crossProduct(vec2);
all functions that take in vec1 are the primary vector to do an operation on.
float vector3::absDotProduct  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Calculates the absolute dot (scalar) product of this vector with another.
This function work similar dotProduct, except it use absolute value of each component of the vector to computing.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be used for the operation. 
vec2_Y  : This is the Y Axis of the vector which will be used for the operation. 
vec2_Z  : This is the Z Axis of the vector which will be used for the operation. 
float vector3::angle  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Gets the angle between 2 vectors.
Vectors do not have to be unitlength but must represent directions.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be used for the operation. 
vec2_Y  : This is the Y Axis of the vector which will be used for the operation. 
vec2_Z  : This is the Z Axis of the vector which will be used for the operation. 
float3 vector3::crossProduct  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Calculates the crossproduct of 2 vectors, i.e. vector that lies perpendicular to them both.
The crossproduct is normally used to calculate the normal vector of a plane, by calculating the crossproduct of 2 nonequivalent vectors which lie on the plane (e.g. 2 edges of a triangle). For a clearer explanation, look a the left and the bottom edges of your monitor's screen. Assume that the first vector is the left edge and the second vector is the bottom edge, both of them starting from the lowerleft corner of the screen. The resulting vector is going to be perpendicular to both of them and will go inside the screen, towards the cathode tube (assuming you're using a CRT monitor, of course).
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be used for the operation. 
vec2_Y  : This is the Y Axis of the vector which will be used for the operation. 
vec2_Z  : This is the Z Axis of the vector which will be used for the operation. 
int vector3::directionEquals  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z,  
float  tolerance  
) 
Returns whether this vector is within a directional tolerance of another vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be compared against. 
vec2_Y  : This is the Y Axis of the vector which will be compared against. 
vec2_Z  : This is the Z Axis of the vector which will be compared against. 
tolerance  : The maximum angle in degrees by which the vectors may vary and still be considered equal 
float vector3::distance  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Returns the distance to another vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be compared against. 
vec2_Y  : This is the Y Axis of the vector which will be compared against. 
vec2_Z  : This is the Z Axis of the vector which will be compared against. 
float vector3::dotProduct  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Calculates the dot (scalar) product of this vector with another.
The dot product can be used to calculate the angle between 2 vectors. If both are unit vectors, the dot product is the cosine of the angle; otherwise the dot product must be divided by the product of the lengths of both vectors to get the cosine of the angle. This result can further be used to calculate the distance of a point from a plane.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be used for the operation. 
vec2_Y  : This is the Y Axis of the vector which will be used for the operation. 
vec2_Z  : This is the Z Axis of the vector which will be used for the operation. 
float4 vector3::getRotationTo  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z,  
float  fallbackVec_X,  
float  fallbackVec_Y,  
float  fallbackVec_Z  
) 
Gets the shortest arc quaternion to rotate this vector to the destination vector.
If you call this with a dest vector that is close to the inverse of this vector, we will rotate 180 degrees around the 'fallbackAxis' (if specified, or a generated axis if not) since in this case ANY axis of rotation is valid.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which is set as the destination. 
vec2_Y  : This is the Y Axis of the vector which is set as the destination. 
vec2_Z  : This is the Z Axis of the vector which is set as the destination. 
fallbackVec_X  : This is the X Axis of the fallback vector. 
fallbackVec_Y  : This is the Y Axis of the fallback vector. 
fallbackVec_Z  : This is the Z Axis of the fallback vector. 
int vector3::isNAN  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Check whether this vector contains valid values.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
int vector3::isZeroLength  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Returns true if this vector is zero length.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
float vector3::length  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Returns the length (magnitude) of the vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
float3 vector3::midPoint  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Returns a vector at a point half way between this and the passed in vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be used for the operation. 
vec2_Y  : This is the Y Axis of the vector which will be used for the operation. 
vec2_Z  : This is the Z Axis of the vector which will be used for the operation. 
float vector3::normalise  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Normalises the vector.
This method normalises the vector such that it's length / magnitude is 1. The result is called a unit vector. Most of the time, you will want to use normalisedCopy() to get the normalised float3 returned.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
float3 vector3::normalisedCopy  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
As normalise, except that this vector is unaffected and the normalised vector is returned as a copy.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
float3 vector3::perpendicular  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Generates a vector perpendicular to this vector (eg an 'up' vector).
This method will return a vector which is perpendicular to vector 1. There are an infinite number of possibilities but this method will guarantee to generate one of them.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
int vector3::positionCloses  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z,  
float  tolerance  
) 
Returns whether this vector is within a positional tolerance of another vector, also take scale of the vectors into account.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be compared against. 
vec2_Y  : This is the Y Axis of the vector which will be compared against. 
vec2_Z  : This is the Z Axis of the vector which will be compared against. 
tolerance  : The amount (related to the scale of vectors) that distance of the vector may vary by and still be considered close 
int vector3::positionEquals  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z,  
float  tolerance  
) 
Returns whether this vector is within a positional tolerance of another vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be compared against. 
vec2_Y  : This is the Y Axis of the vector which will be compared against. 
vec2_Z  : This is the Z Axis of the vector which will be compared against. 
tolerance  : The amount that each element of the vector may vary by and still be considered equal 
float3 vector3::primaryAxis  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Extract the primary (dominant) axis from this direction vector.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
float3 vector3::randomDeviant  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  randomAngle,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Generates a new random vector which deviates from this vector by a given angle in a random direction.
This method assumes that the random number generator has already been seeded appropriately.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
angleDeg  : The angle at which to deviate 
vec2_X  : This is the X Axis of the vector which you are using as a direction. 
vec2_Y  : This is the Y Axis of the vector which you are using as a direction. 
vec2_Z  : This is the Z Axis of the vector which you are using as a direction. 
float3 vector3::reflect  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Calculates a reflection vector to the plane with the given normal .
NB assumes 'this' is pointing AWAY FROM the plane, invert if it is not.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the normal to reflect on. 
vec2_Y  : This is the Y Axis of the normal to reflect on. 
vec2_Z  : This is the Z Axis of the normal to reflect on. 
float vector3::squaredDistance  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z,  
float  vec2_X,  
float  vec2_Y,  
float  vec2_Z  
) 
Returns the square of the distance to another vector.
This method is for efficiency  calculating the actual distance to another vector requires a square root, which is expensive in terms of the operations required. This method returns the square of the distance to another vector, i.e. the same as the distance but before the square root is taken. Use this if you want to find the longest / shortest distance without incurring the square root.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 
vec2_X  : This is the X Axis of the vector which will be compared against. 
vec2_Y  : This is the Y Axis of the vector which will be compared against. 
vec2_Z  : This is the Z Axis of the vector which will be compared against. 
float vector3::squaredLength  (  float  vec1_X, 
float  vec1_Y,  
float  vec1_Z  
) 
Returns the square of the length(magnitude) of the vector.
This method is for efficiency  calculating the actual length of a vector requires a square root, which is expensive in terms of the operations required. This method returns the square of the length of the vector, i.e. the same as the length but before the square root is taken. Use this if you want to find the longest / shortest vector without incurring the square root.
vec1_X  : This is the X Axis of the vector which you are going to use an operation on. 
vec1_Y  : This is the Y Axis of the vector which you are going to use an operation on. 
vec1_Z  : This is the Z Axis of the vector which you are going to use an operation on. 