Path::defaultToleranceForTesting - what exactly is this?


#1

Hello,
could anyone, please, describe what exactly does:
const float Path::defaultToleranceForTesting

and
const float Path::defaultToleranceForMeasurement

And what is the value it returns.

In the documentation there is nothing about that, or I just can’t find anything. It looks like that


#2

They don’t return anything because they’re static member variables - not methods… Their values are 1.0 for testing and 0.6 for measurement:


#3

Ok I can see it now. Thanks.


#4

When you look at: https://github.com/WeAreROLI/JUCE/blob/efddea0effc31f0b24423aabb8b21cf97863938b/modules/juce_graphics/geometry/juce_Path.h those values are used as a default value for the tolerance arguments in methods like
contains(), intersectsLine() (both testing) and e.g. getLength() (measuring).

When measuring the length, the path first is split into linear segments, whose lengths are added. Depending on the tolerance the linear segments are smaller or longer. Longer ones (high tolerance) will of course not perfectly represent the length of that path. See the figure in the “General Approach” section of https://en.wikipedia.org/wiki/Arc_length

Don’t be afraid of searching the JUCE codebase (modules directory) for variables, methods etc and looking at the code. They did a very good job in keeping the code readable :slight_smile:


#5

Thanks, yes I always search direct Juce code if I don’t understand something. But due to my low programming skills very often oryginal code is hard to understand for me.
So thanks for explanation.