Usage

Syntax: vectorlen(array v);
Returns the magnitude 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 vectordist does, is that it calculates the magnitude of vector v using the following calculation:
magnitude = √(v1² + v2² + v3²)
magnitude = (v[0]^2 + v[1]^2 + v[2]^2)^0.5

Example

function onCreated() {
  temp.u = {1, 7, 1};

  temp.magnitude = vectordist(v);
}

... Will set temp.magnitude to 7.141428428 (√51).

Categories

CategoryFunctionClientside
CategoryFunctionServerside

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

Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by WikkaWiki