Usage
Syntax: vectordist(array u, array v);
Returns the distance between vector u and vector v.
Explanation
Vectors are often written as <x,y,z>, however in Graal they are written as arrays and often use these syntaxes: {x, y, z} or {x, y}.
What vectordist does, is that it calculates the distance between vector u and vector v.
distance = √((u1-v1)² + (u2-v2)² + (u3-v3)²)
distance = ((u[0]-v[0])^2 + (u[1]-v[1])^2 + (u[2]-v[2])^2)^0.5
The calculation done by the function is based on the pythagorean theorem.
Example
function onCreated() { temp.u = {30, 30, 0}; // Player 1 stands at <30, 30, 0> temp.v = {35, 30, 0}; // Player 2 stands at <35, 30, 0> temp.distance = vectordist(u, v); }
... Will set temp.distance to 5, since the distance between u and v is 5
Categories
CategoryFunctionClientside
CategoryFunctionServerside
There are no comments on this page. [Add comment]