Vector3D.CompareTo seems to not be working for me

Hi, I am not sure why the CompareTo function is not giving me a result of 0 when the two vectors I am comparing are the same? Any thoughts?? Please see image:

thanks!

Bradley

Welcome to floating point math. Your vectors are not EXACTLY equal (look at the 10th decimal place or so), which is what the function is looking for, there is zero tolerance built into it…

What you might want to use instead is IsVectorParallelTo() and a very small angle tolerance which will compensate for the fuzziness… Or perhaps another way would be to subtract one from the other and then check the result with IsVectorTiny(with some small tolerance)

–Mitch

Also EpsilonEquals allows you to compare with some tolerance level.

Thanks! Why does that one never stick in my head? --Mitch

thank you!! EpsilonEquals works perfectly!

Bradley

I also realized there was a different mistake in my loop where I wasn’t updating the new objects inside of the loop, so objects were copying onto themselves…