Difference between revisions of "VectorA:length"
From ComputerCraft Wiki
(Created page with "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 ...") |
(corrected link) |
||
| (6 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | Returns the length of the vector | + | {{lowercase}} |
| − | + | {{Function | |
| − | + | |name=vector:length | |
| − | local a = vector.new(1, 2, 3) | + | |returns={{type|number}} |
| + | |api=vector | ||
| + | |addon=ComputerCraft | ||
| + | |desc=Returns the length of the vector. | ||
| + | |examples= | ||
| + | {{Example | ||
| + | |desc=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 | ||
| + | |desc=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) | local c = math.sqrt(a.x^2 + a.y^2 + a.z^2) | ||
--c = 3.7416575 | --c = 3.7416575 | ||
| + | }} | ||
| + | }} | ||
| − | + | [[Category:API_Functions]] | |
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
| − | + | ||
Latest revision as of 13:25, 18 July 2013
| Returns the length of the vector. | |
| Syntax | vector:length() |
| Returns | number |
| Part of | ComputerCraft |
| API | vector |
Examples
| 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 |
| 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 |