Main Index : Reference :
[float] vlen([vector] v)
v is a vector.
vlen() returns the vector length of v, that is the distance from origo to a point at the coordinates v. Mathematically this is calculated with sqrt(v.x*v.x + v.y*v.y + v.z*v.z).
// Outputs "vlen(v) = 3.0000".
var v = vector(1.0,2.0,2.0);
var a = vlen(v);
println("vlen(v) = ",a);
// vlen() can be used to measure the distance between
// two points or object positions.
//
// Outputs "distance(p1,p2) = 500.0000".
distance(p1,p2)
{
// Calculates the length of the vector
// that goes from p1 to p2.
return vlen(p2-p1);
}
var p1 = obj1->GetPosition(); // p1 = [100.0,0.0,0.0]
var p2 = obj2->GetPosition(); // p2 = [-200.0,400.0,0.0]
println("distance(p1,p2) = ",distance(p1,p2));