Kernel SDK Developer's Guide > Working with the Ge Library > Working with Tolerances
Working with Tolerances

Tolerances represent a measure of equivalence in operations with vectors and points and are used as parameters of many methods in the Ge library. A tolerance is represented by an object of the OdGeTol class and always has a default value, as defined in OdGeContext::gTol. For example, the isClosed() method determines whether the start and end points are within the defined tolerance, and if they are, returns the true value.

To create a new tolerance object, use the following OdGeTol() constructors:

  • OdGeTol::OdGeTol(double t = 1.e-10) — Creates a tolerance using the same value for vectors and points.
  • OdGeTol::OdGeTol(double t1, double t2) — Creates a tolerance using the t1 value for vectors and t2 value for points.

The OdGeTol class contains the setEqualPoint() and setEqualVector() methods for setting the tolerance of points and vectors:

void OdGeTol::setEqualPoint(double val);
void OdGeTol::setEqualVector(double val);

The OdGeTol class also contains the equalPoint() and equalVector() methods for obtaining the tolerance of points and vectors:

double OdGeTol::equalPoint() const;
double OdGeTol::equalVector() const;

The equalPoint and equalVector tolerance values are used as follows:

  • Two points, p1 and p2, are equal if (p1 - p2).length() <= equalPoint
  • Two vectors, v1 and v2, are equal if (v1 - v2).length() <= equalVector
  • Two vectors, v1 and v2, are parallel if (v1/v1.length() - v2/v2.length()).length() < equalVector
  • OR (v1/v1.length() + v2/v2.length()).length() < equalVector
  • Two vectors, v1 and v2, are perpendicular if abs((v1.dotProduct(v2))/(v1.length()*v2.length())) <= equalVector
  • Two lines or rays are parallel (or perpendicular) if their directional vectors are parallel (or perpendicular)
Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.