A strange case of unequal vectors being treated as equal? (AutoCAD .net API)

_config.yml

My estimable colleagues over at Siderinnet1.typepad.com wrote an interesting post. It seems that in certain cases, two vectors which are obviously not equal are treated as being equal. I postulated that perhaps this strange form of equality was due to the hash code algorithm of the two vectors being the same? The question was an interesting one so after being prompted I wrote a post on it.

The answer to the immediate question: it seems that the hash codes are NOT the same. Which means that AutoCAD is somehow rendering these two vectors as being equal. How curious! Why is this the case?

Here is the code:

The solution to the problem

But the solution to this problem is laughable simple. It seems that when we ask AutoCAD to see whether two vectors are equal, it assumes a tolerance of Global (i.e. Tolerance.Global.EqualVector). Now if the Global tolerance is larger than the vectors we are considering, then obviously AutoCAD will treat those two vectors as being equal, even though they are in completely opposite directions and even though they return completely different hashcodes!

Written on December 8, 2017