Vector.AngleWithVector node glitch

What on earth is going on with this node?!

Once I round it I get the correct results but where on earth is it getting those numbers from in the first place?! :frowning:

Welcome to the land of floating point math.

4 Likes

Hello,
The nodes must keep the residuals of calculations after processing, this must be the reason

Cordially
christian.stan

Are there plans to fix this? Or has it been fixed in a later version?

That’s from R21

Calculation residues bring precision to the result, everything is a matter of compromise (you found a workaround with Math.round, it’s good in the end)

Cordially
christian.stan

This is a floating point issue - check the video linked above for all the specifics, or run a search for “floating point math” for further information on it.

The TLDR of it: The reason floating point errors exist is because of how your computer handles numbers at a foundational level. Nothing on the Dynamo side could completely fix this without also overhauling Revit, Windows, .Net, Python, and just about every other tool on your system - that is how foundational this is. While nodes like the revised equal node which accounts for a tolerance can be utilized to remediate floating point issues, because you’re writing the code (what all Dynamo use is), it’s up to you to decide how to account for floating point issues.

At a more detailed level, floating point issues are what programs have to account to ensure that all our values can be stored as 32 or 64 bit values while accounting for decimal values and negative values. A static point would remove the error to some extent, but you’d be quite limited in both the upper limit (<8 billion) and the precision of decimals (1/64 if memory serves), neither of which work for AEC use due to the variety of units utilized and the required precision. As such a floating point is utilized, but this means we can’t be as precise as we would like - there are infinite numbers between any one number which could be returned - we simply cannot express them all. But with floating point we’re consistently well within the tolerances of construction, if not capable of measuring at the atomic scale in some cases (10^-12 of a millimeter).