Notifications
Clear all
[Closed] little angle math problem
Page 2 / 2
Prev
Jun 25, 2015 10:12 am
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
Jun 25, 2015 10:12 am
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
)
Jun 25, 2015 10:12 am
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.
Page 2 / 2
Prev