Notifications
Clear all

[Closed] place a point3 on the line between 2 pos values

I’s like to calculate a point p3 at an arbitrary distance on the line between p1 and p2

I am trying to adapt a mel script I found

(
        p1=[a point3 value]
        p2=[another point3 value]

	--calculate direction vector & normalize
	v = normalize (p2-p1)

	--set ratio along the line the new point should appear
	ratio=0.5 

	--calculate new position
	p3 = p1 + (ratio * v); 

	point pos:p3 name:"p3"

)

it’s not quite working
p3 shows up on the line but not at the correct distance

2 Replies

take out the normalize or its length(p2 – p1) * 0.5 * v

thanks, that did it.