Grasshopper

algorithmic modeling for Rhino

Hi David,

the math equality component seems to be wrong here:

Views: 801

Replies to This Discussion

I'd like to see the actual value of the distance rather than rounded to 6 decimal places. If the distance isn't 0.0 but 0.0000000000007 then it would still display as 0.0 but it wouldn't be equal to 0.0

Equality for floating point numbers can never be trusted. Every mathematical operation can introduce some noise in the least significant digits of a number and this noise will subsequently wreck havoc with any equality test. The only proper solution is to test for equality within a certain tolerance. For example you could compare the absolute value of the difference between the two numbers to a threshold value. So instead of:

A = B

You'll use:

|A-B| < 1e-8

where 1e-8 is 0.00000001 and represents the tolerance.

--

David Rutten

david@mcneel.com

Tirol, Austria

Thank you David. I'll do as you suggested.

A.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service