Difference between revisions of "VectorA:dot"

From ComputerCraft Wiki
Jump to: navigation, search
(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...")
 
Line 1: Line 1:
 
Returns the dot product of two vectors
 
Returns the dot product of two vectors
  
A dot product can be represented by multiplying the corresponding values together and then summing the results.
+
A dot product can be represented by multiplying the corresponding values together and summing the results.
  
 
More information on dot products can be found at [http://en.wikipedia.org/wiki/Dot_product]
 
More information on dot products can be found at [http://en.wikipedia.org/wiki/Dot_product]

Revision as of 09:43, 23 February 2013

Returns the dot product of two vectors

A dot product can be represented by multiplying the corresponding values together and 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