Notifications
Clear all

[Closed] little angle math problem

Nice one aaandres! That works great.

Thanks everyone for your input

 lo1

I don’t have time to check at the moment, but I think I’ve done this before and I think it involved atan2 function to get the 360 degree angle between the segments.

http://stackoverflow.com/questions/21483999/using-atan2-to-find-angle-between-two-vectors

delete objects
knots = #([-80,0,0], [-80,-50,0], [-30,-50,0], [-30,-30,0], [30,-30,0], [30,-50,0], [80,-50,0], [80,0,0], [-80,0,0])
sp = line wirecolor:yellow 
s = addnewspline sp 
for p in knots do
(
	addknot sp s #corner #line p
)
updateshape sp
setKnotSelection sp s #(1, knots.count)
weldSpline sp 0.0

num = numknots sp
sss = for k=1 to num collect
(
	ss = line wirecolor:red
	addnewspline ss
	
	a = getknotpoint sp 1 (if k == 1 then num else (k-1))
	c = getknotpoint sp 1 k
	b = getknotpoint sp 1 (if k == num then 1 else (k+1))
	v1 = normalize (a-c)
	v2 = normalize (b-c)
	d = -(normalize (v1 + v2)) * 10
	
	/* if you want all out do next line >>> */
	-- if dot (cross v1 v2) z_axis > 0 do d = -d
		
	addknot ss 1 #corner #line c
	addknot ss 1 #corner #line (c + d)
	updateshape ss
	ss
)

Yes, that was the case.
And you have used the same than me (in a better way), comparing with the z_axis.
I’m not sure that with a complex 3D line this will work.

Thanks denisT that work really well too

Page 2 / 2