Usage
Syntax: vectornormalize(array v);
Returns the unit length of 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 vectornormalize does, is that it calculates the unit length of the vector by simply dividing the vector by the magnitude of the vector.
m = magnitude of vector (vectorlen)
unitlength = <v1/m, v2/m, v3/m>
Example
function onCreated() { temp.v = {1, 1, 0}; temp.unitlength = vectornormalize(v); }
... Will set temp.unitlength to {0.707106769, 0.707106769, 0}
Categories
CategoryFunctionClientside
CategoryFunctionServerside