VectorA:dot

From ComputerCraft Wiki
Revision as of 09:42, 23 February 2013 by MafiaMoe (Talk | contribs) (Created page with "Returns the dot product of two vectors A dot product can be represented by multiplying the corresponding values together and then summing the results. More information on do...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Returns the dot product of two vectors

A dot product can be represented by multiplying the corresponding values together and then summing the results.

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

Code representation:

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


Code example:

local a = vector.new(1, 2, 3)
local b = vector.new(4, 5, 6)

local c = a:dot(b)

print(c)
--32