ScriptSpot

Forum topic · General Scripting

Move object along vector

By JokerMartini · 2013-06-18

Downloads
Description

How do I calculate the move of an object off of the vector of two given points?

The 2 green points are the main ends.
I want to move the yellow point perpendicular to the green points by an amount of X

http://www.scriptspot.com/files/vector.png

Comments (1)

start

JokerMartini · 2013-06-18


(
radiusX = 30.0
radiusY = 20.0
offset = 10.0

delete objects

clearlistener()
/* Create Corner Points */
startPt = point pos:[0,0,0] wirecolor:blue size:4
endPt = point pos:[radiusX,radiusY,0] wirecolor:blue size:4

center = (endPt.pos + startPt.pos)/2

nvec = (normalize endPt.pos)
d = (distance endPt.pos startPt.pos)/2 + offset
point pos:(nvec*(d)) size:2 wirecolor:white

circle pos:center radius:((distance startPt.pos endPt.pos)/2) wirecolor:red
)