Grasshopper

algorithmic modeling for Rhino

Shouldn't the output from the Curve/Line intersect be {0.0, 4.0, 0.0)} ?



That 3 with 16 zeros in front of it is really causing some problems here!

Views: 236

Replies to This Discussion

Hi Shawn,

mathematics inside the computer isn't anywhere near as accurate as people usually think. -3.8348e-17 is pretty close to zero. You could just round the coordinates to 6 decimal places, or you try and make your downstream logic smart enough to deal with the noisy data.

Why is it causing problems?

--
David Rutten
david@mcneel.com
Poprad, Slovakia
I had been using a VB component with ToString to do a quick and dirty comparison of the values of two inputs, points in this case. Apparently it's too quick and too dirty. Using the ToString was nice because it allowed me to do the comparison on numbers, points lines and curves with the same component without having to get into managing the data. I imagine I can add a routine to parse the string and truncate after so many decimals. In this case, I guess I could force the value to zero, but talk about dirty. ;)

How about an optional argument to the ToString methods that allows you to input the number of decimals to return? XD
Yep, comparing floating point numbers that do not originate from the exact same process will almost never work. There's almost always some puny random noise in the least-significant digits. A lot of people know that division is slower than multiplication, but almost nobody knows that subtraction is much less accurate than addition (though practically all operations suffer from inaccuracy). This is not because of poor software, it is a necessary outcome of the way numbers are defined in computing.

As you can imagine, there's a lot of additions and subtractions going on inside any given Curve|Curve intersection computation.

To do this right, you do not only have to special case every single data-type and cater for fuzzy comparisons, but you should even take the document tolerance into account.

--
David Rutten
david@mcneel.com
Poprad, Slovakia

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service