Notifications
Clear all
[Closed] Acos return #ind
Dec 04, 2014 4:55 pm
I know somebody says something about bit.isNan when #ind occurs but I really dind’t find a solution for that.
I have two lines in 2d(top view, no z needed) and I’m trying to retrieve an angle between those.
So the question is: how can I obtain the degrees between the two splines without #ind errors?
Acos, as the docs suggest, would return a float. Does that represent the angle? eg. 45.0= 45 degrees?
first_line = selection[1]
second_line = selection[2]
a = getKnotpoint first_line 1 1
b = getKnotpoint first_line 1 2
first_vector = b-a
print first_vector
c = getKnotpoint second_line 1 1
d = getKnotpoint second_line 1 2
second_vector = d-c
print second_vector
nv1 = normalize first_vector
nv2 = normalize second_vector
format "nv1 is %" nv1
format "nv2 is %" nv2
dotProduct = nv1.x*nv2.x + nv1.y*nv2.y
format "dotProduct is %" dotProduct
result = acos dotProduct
format "final resukt is %" result
As you can see, debugging with format led me to isolate the problem on the last operation(acos doProduct). I know I could have used prewritten function like dot but I need it for learning purposes.