> As an erstwhile scientific programmer I still feel the need to point out that with floating point comparisons it might be a good idea to use a tolerance calculation somewhere....
sure ... but I'm waiting pedagogically for the OP to come back before explaining how to get the correct angle out of the dot-product ;)