Notifications
Clear all
[Closed] Acos problem
Apr 01, 2011 9:40 am
obj1 = $obj1
obj2 = $obj2
obj = $obj
V1 = obj1.transform.pos - obj.transform.pos
V2 = obj2.transform.pos - obj.transform.pos
N1 = normalize V1
N2 = normalize V2
Ang = acos (dot N1 N2)
Hello! I use this code and its working well in most case. But some times Ang return -1.#IND – it makes a mess in results of function based on Ang value.
How to avoid/fix it?
2 Replies
1 Reply
Apr 01, 2011 9:40 am
denisT: thank you, I will try.
meanwhile I get good result with another method of calc Ang (oroginal fn by VG)
fn getalfa p1 p2 p3 = (
v1=normalize(p2-p1)
v2=normalize(p3-p1)
z = cross v1 v2
len = length (z)
return atan2 len (dot v1 v2)
)