One Million Worlds Wiki
Advertisement

A Vector is a data type used within scripts. It can be created using the function vec(x,y,z) e.g. vec(1,2,3)

Available functions[]

add(Vector)[]

Adds the two vectors and returns annother vector containing the result.

var a = vec(1,2,3);
var b = vec(10,20,30);

var c = a.add(b); //c will be 11,22,33

negate()[]

Reverses the vector and returns a new vector containing the result

var a = vec(1,2,3);
var c = a.negate(); //c will be -1,-2,-3

length()[]

Returns the length of the vector.

var a = vec(1,2,0);
var c = a.length() ; //c will be 2.23, because sqrt(1*1+2*2+0*0)

dot(Vector)[]

Calculates the dot product with another vector; this is basically a measure of how much the two vectors are pointing in the same direction.

var a = vec(1,2,3);
var b = vec(10,20,30);

var c = a.dot(b); //c will be 140, 1*10+2*20+3*30
Advertisement