Difference between revisions of "VectorA:length"
From ComputerCraft Wiki
Line 1: | Line 1: | ||
{{lowercase}} | {{lowercase}} | ||
{{Function | {{Function | ||
− | |name=vector:length | + | |name=vector:length |
|returns=[[float (type)|float]] | |returns=[[float (type)|float]] | ||
|api=vector | |api=vector |
Revision as of 14:25, 23 February 2013
Function vector:length | |
Returns the length of the vector. | |
Syntax | vector:length() |
Returns | float |
Part of | ComputerCraft |
API | vector |
Examples
Example | |
Takest the length of the vector and prints it. | |
Code |
local a = vector.new(2, 5, 9) local c = a:length() print(c) --10.488089 |
Example | |
Code to recreate the function. Gives insight into what the function does. | |
Code |
local a = vector.new(1, 2, 3) local c = math.sqrt(a.x^2 + a.y^2 + a.z^2) --c = 3.7416575 |