Snippets

John Martini GetCenterVector demonstrates how to find the vector between two known vectors. http://stackoverflow.com/questions/11417626/how-to-get-the-vector-between-two-vectors

Created by John Martini
ptA = [7,5,0] -- center
ptB = [4,4,0]
ptC = [6.5,1,0]
ptD = [0,0,0]

clearlistener()
-- the vector from A to B is
vAB = ptB-ptA 

-- the vector from A to C is
vAC = ptC-ptA

-- Adding these together yields the vector from A to D: (-350, -500).
vAD = vAB + vAC

-- Adding that vector to point A yields the coordinates of the point D: (350, 0)
ptD = ptA + vAD

delete objects
point pos:ptA size:1 wirecolor:red
point pos:ptB size:1 wirecolor:blue
point pos:ptC size:1 wirecolor:blue
point pos:ptD size:1 wirecolor:green

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.