Difference between revisions of "VectorA:length"

From ComputerCraft Wiki
Jump to: navigation, search
Line 11: Line 11:
 
  local a = vector.new(2, 5, 9)
 
  local a = vector.new(2, 5, 9)
 
    
 
    
  local c = a.length()
+
  local c = a:length()
 
   
 
   
 
  print(c)
 
  print(c)
 
  --10.488089
 
  --10.488089

Revision as of 10:59, 23 February 2013

Returns the length of the vector

Code representation:

local a = vector.new(1, 2, 3)

local c = math.sqrt(a.x^2 + a.y^2 + a.z^2)

--c = 3.7416575

Code example:

local a = vector.new(2, 5, 9)
 
local c = a:length()

print(c)
--10.488089