Vertex Variables  (Animation Script)

VERTEX
3 component vector
Local variable


Members
x, y, z

Operators
( . ) Invoke function or select .x/.y/.z component


Declaration
At beginning of script, one or more per line

Note: Assigning a scalar float value to a VERTEX variable copies the value to all x/y/z components

VERTEX VariableName1
VERTEX VariableName2, VariableName3


VERTEX Functions

Function Parameters
1 or 2 VERTEX variable types
3 constant or VERTEX variable components specified by (.x/.y/.z)


Parameter Modifiers
( - ) Use negative value for function parameter

Notations

VERTEX - Declared VERTEX variable / object center from named Object variable / surface normal from named Surface variable
float - Scalar floating point constant or VERTEX variable component (.x/.y/.z)
Dest - Destination VERTEX variable


Functions Description and parameter type variations
Set Sets VERTEX member component values to parameter(s)

Set(VERTEX V)  
Set(float x, float y, float z)  
 
Add
Sub
Mul
Div
Applies operation to all 3 components

Add(VERTEX V)  
   Add/Sub/Mul/Div of two VERTEX variables using 1 VERTEX parameter
   Dest variable is 1st source parameter, V is 2nd source parameter
   Dest = Dest VERTEX + Source VERTEX V parameter

Mul(VERTEX V1, VERTEX V2) 
   Add/Sub/Mul/Div of two VERTEX variables
   Dest = Source VERTEX V1 * Source VERTEX V2 parameter

Sub(float x, float y, float z) 
   Add/Sub/Mul/Div using 3 scalar float parameters
   Dest variable is 1st source parameter, 3 scalar float value are 2nd source parameter
   Dest.x = Dest.x - x
   Dest.y = Dest.y - y
   Dest.z = Dest.z - z

*Divide by 0 results in 0

Min
Max
Minimum or Maximum value of each component

Min(VERTEX V)
   Min or Max of two VERTEX variables using 1 VERTEX parameter
   Dest variable is 1st source parameter, V is 2nd source parameter
   Dest.x = Min(Dest.x, V.x)
   Dest.y = Min(Dest.y, V.y)
   Dest.z = Min(Dest.z, V.z)

Max(VERTEX V1, VERTEX V2)
   Min or Max of two VERTEX variables   
   Dest.x = Max(V1.x, V2.x)
   Dest.y = Max(V1.y, V2.y)
   Dest.z = Max(V1.z, V2.z)

Max(float x, float y, float z) 
   Min or Max using 3 scalar float parameters
   Dest.x = Max(Dest.x, x)
   Dest.y = Max(Dest.y, y)
   Dest.z = Max(Dest.z, z)

TranslateV Translate along a vector

TranslateV(VERTEX V, float t)
   Dest = Dest VERTEX + V * t

Rotate Rotates a VERTEX, rotation degree for each axis is from V/C parameters

Rotate(float x, float y, float z)
Rotate(VERTEX V)
   Rotate Dest around X, Y, Z axis using (0, 0, 0) as rotation center

Rotate(float x, float y, float z, VERTEX Center)
Rotate(VERTEX V, VERTEX Center)
   Rotate Dest around X, Y, Z axis using VERTEX Center parameter as rotation center

*All rotations are specified in degrees

RotateV

Rotates a VERTEX around a vector

RotateV(VERTEX V, float degree)
   Rotate Dest around V axis using (0, 0, 0) as rotation center

RotateV(VERTEX V, float degree, VERTEX Center)
   Rotate Dest around V axis using VERTEX Center parameter as rotation center

*All rotations are specified in degrees

Length Returns length of a VERTEX or distance between 2 VERTEX types
Return value is floating point scalar that can be written to a VERTEX variable or component (.x/.y/.z)

float Lenght()
   returns length of a VERTEX variable, length = √(x2 + y2 + z2)

float Length(VERTEX V)
   returns distance between Dest VERTEX and Source VERTEX variable, distance = √((Dest.x - V.x)2 + (Dest.y - V.y)2 + (Dest.z - V.z)2)

DotP
Vector dot product
Return value is floating point scalar that can be written to a VERTEX variable or component (.x/.y/.z)

float DotP(VERTEX V)
   returns Dest.x * V.x + Dest.y * V.y + Dest.z * V.z

UnitV Unit Vector (vector normalization)
Return value is floating point scalar that can be written to a VERTEX variable or component (.x/.y/.z)

float UnitV()
   Dest = (Dest.x / length, Dest.y / length, Dest.z / length),  length = length of Dest VERTEX
   returns length

float UnitV(VERTEX V)
   Calculates unit vector from Dest to V
   Dest = ((V.x - Dest.x) / length, (V.y - Dest.y) / length, (V.z - Dest.z) / length),  length = length from Dest to VERTEX V
   returns length

CrossP
Vector cross product
Calculates cross product of two vectors

CrossP(VERTEX V)
   Dest = Dest x V

CrossP(VERTEX V1, VERTEX V2) 
   Dest = V1 x V2



Examples

VERTEX v1, v2, v3

//Set from constant values
v1.Set(0.707, 0, -707)
v2.Set(0, 1, 0)

//Set from vertex components/constants
v3.Set(v1.z, -v1.x, 1)

//Shuffle x/z
v3.Set(v3.z, v3.y, v3.x)
 
//Set from VERTEX variable
v3.Set(v2)

//Add 2 VERTEX types
v3.Add(v1)
v3.Add(v1, -v2)

//Multiply y component by 2
v3.Mul(1, 2, 1)

//Subtract from x component
v3.Sub(-v1.x, 0, 0)

//Translate along a vector
v3.TranslateV(v1, -5)

//Dot product, assign to only y component
v3.y = v1.DotP(v2)
//Assign to x/y/z components
v3 = v1.DotP(v2)

//Cross product
v3.CrossP(v1, -v2)

//Shuffle x/z component
v1.Set(v1.z, v1.y, v1.x)

//Min
v1.Min(v2)

//Max
v3.Max(4, -7, v1.y)