Developer Documentation

Vector data type for scripting

The vector data type is corresponding to the Vec3d type in C++. The implementation of the scripting type is done in prototypeVec3d.

You can use the following functions:

var vec = Vector(1,2,3)
var vec2 = Vector(10,20,30)
vec.multiply(0.5) // Multiply vec with 0.5
vec.add(vec2) // Add vec2 to vec
vec.sub(vec2) // Subtract vec2 from vec
var norm = vec.norm() // Calculate the length of the vector
var sqrnorm = vec.sqrnorm() // Calculate the squared length of the vector
var sprod = vec.sprod(vec) //Compute scalar product with the vector and itself
vec.normalize() // Normalize vector
vec.zero() // Set all components of the vector to zero
print(vec) // Output vector to the console