From ComputerCraft Wiki
Jump to: navigation, search

Grid Redstone.png  Function vector:dot
Returns the dot product of two vectors.
Syntax vector:dot(vector vect)
Returns vector
Part of ComputerCraft
API vector


Grid paper.png  Example
Creates a dot product of two vectors and prints the resulting vector.
local a =, 2, 3)
local b =, 5, 6)

local c = a:dot(b)


Grid paper.png  Example
Code to recreate the function. Gives insight into what the function does.
local a =, 2, 3)
local b =, 2, 5)

local c = ((a.x * b.x) + (a.y * b.y) + (a.z * b.z))
--c = 18

In the case of dot products, a:dot(b) will equal b:dot(a).

More information about dot products can be found at [1]