vectorA:dot

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

Examples

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

local c = a:dot(b)

print(c)
--32



Grid paper.png  Example
Code to recreate the function. Gives insight into what the function does.
Code
local a = vector.new(1, 2, 3)
local b = vector.new(-1, 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]

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox