##### 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 = <v

^{1}/m, v

^{2}/m, v

^{3}/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

There are no comments on this page. [Add comment]