Yes, that is an unhelpful error.
I'm surprised no-one has spotted it before. Have you checked?
Edit I should have added that your heading might be misleading. The dot product command seems to return the correct value so it's not clear what is bugged. For example, the following code prints out the argument of the acos command when it returns the wrong answer
null = make vector3(1)
null = make vector3(2)
for i = 1 to 100
x# = rnd(101) - 50.5
y# = rnd(101) - 50.5
z# = rnd(101) - 50.5
set vector3 1, x#, y#, z#
set vector3 2, -x#, -y#, -z#
dp# = dot product vector3(1,2)/(length vector3(1)*length vector3(2))
ang#=acos(dp#)
temp$=str$(ang#)
if temp$="-1.#IND"
print dp#, " ", ang#
wait key
endif
next i
end
yet the following code works perfectly:
test# = -1
print test#, " ", acos(test#)
wait key
Certainly annoying whatever the cause.
Edit2 A bit of experimenting suggests the problem is numerical inaccuracies in the division calculations. In other words, your calculation which should lie in the range -1 to +1 might by accident lie outside that range by a small amount. Try this to see what I mean:
null = make vector3(1)
null = make vector3(2)
for i = 1 to 100
x# = rnd(101) - 50.5
y# = rnd(101) - 50.5
z# = rnd(101) - 50.5
set vector3 1, x#, y#, z#
set vector3 2, -x#, -y#, -z#
dp# = dot product vector3(1,2)/(length vector3(1)*length vector3(2))
ang#=acos(dp#)
temp$=str$(ang#)
if temp$="-1.#IND"
text 20, 20, str$(dp#, 12)+ " " + str$(ang#)
wait key
endif
next i
end
That is not a bug in my opinion - it's just an example of the standard limitations of numerical precision that you need to watch out for as a programmer.