![]() |
Open CASCADE Technology Reference Manual 8.0.0
|
The Precision package offers a set of functions defining precision criteria for use in conventional situations when comparing two numbers. Generalities It is not advisable to use floating number equality. Instead, the difference between numbers must be compared with a given precision, i.e. : double x1, x2 ; x1 = ... x2 = ... If ( x1 == x2 ) ... should not be used and must be written as indicated below: double x1, x2 ; double Precision = ... x1 = ... x2 = ... If ( Abs ( x1 - x2 ) < Precision ) ... Likewise, when ordering floating numbers, you must take the following into account : double x1, x2 ; double Precision = ... x1 = ... ! a large number x2 = ... ! another large number If ( x1 < x2 - Precision ) ... is incorrect when x1 and x2 are large numbers ; it is better to write : double x1, x2 ; double Precision = ... x1 = ... ! a large number x2 = ... ! another large number If ( x2 - x1 > Precision ) ... Precision in Cas.Cade Generally speaking, the precision criterion is not implicit in Cas.Cade. Low-level geometric algorithms accept precision criteria as arguments. As a rule, they should not refer directly to the precision criteria provided by the Precision package. On the other hand, high-level modeling algorithms have to provide the low-level geometric algorithms that they call, with a precision criteria. One way of doing this is to use the above precision criteria. Alternatively, the high-level algorithms can have their own system for precision management. For example, the Topology Data Structure stores precision criteria for each elementary shape (as a vertex, an edge or a face). When a new topological object is constructed, the precision criteria are taken from those provided by the Precision package, and stored in the related data structure. Later, a topological algorithm which analyses these objects will work with the values stored in the data structure. Also, if this algorithm is to build a new topological object, from these precision criteria, it will compute a new precision criterion for the new topological object, and write it into the data structure of the new topological object. The different precision criteria offered by the Precision package, cover the most common requirements of geometric algorithms, such as intersections, approximations, and so on. The choice of precision depends on the algorithm and on the geometric space. The geometric space may be : More...
#include <Precision.hxx>
Static Public Member Functions | |
| static constexpr double | Angular () |
| Returns the recommended precision value when checking the equality of two angles (given in radians). double Angle1 = ... , Angle2 = ... ; If ( std::abs( Angle2 - Angle1 ) < Precision::Angular() ) ... The tolerance of angular equality may be used to check the parallelism of two vectors : gp_Vec V1, V2 ; V1 = ... V2 = ... If ( V1.IsParallel (V2, Precision::Angular() ) ) ... The tolerance of angular equality is equal to 1.e-12. Note : The tolerance of angular equality can be used when working with scalar products or cross products since sines and angles are equivalent for small angles. Therefore, in order to check whether two unit vectors are perpendicular : gp_Dir D1, D2 ; D1 = ... D2 = ... you can use : If ( std::abs( D1.D2 ) < Precision::Angular() ) ... (although the function IsNormal does exist). | |
| static constexpr double | Confusion () |
| Returns the recommended precision value when checking coincidence of two points in real space. The tolerance of confusion is used for testing a 3D distance : | |
| static constexpr double | SquareConfusion () |
| Returns square of Confusion. Created for speed and convenience. | |
| static constexpr double | Computational () |
| Returns a precision value at machine epsilon level, used for low-level numerical computations and floating-point comparisons. Unlike the geometric tolerances (Confusion, Intersection, Approximation) which are application-level values for modeling operations, this value represents the fundamental limit of floating-point arithmetic precision. | |
| static constexpr double | SquareComputational () |
| Returns square of Computational. Created for speed and convenience when comparing squared values. | |
| static constexpr double | Intersection () |
| Returns the precision value in real space, frequently used by intersection algorithms to decide that a solution is reached. This function provides an acceptable level of precision for an intersection process to define the adjustment limits. The tolerance of intersection is designed to ensure that a point computed by an iterative algorithm as the intersection between two curves is indeed on the intersection. It is obvious that two tangent curves are close to each other, on a large distance. An iterative algorithm of intersection may find points on these curves within the scope of the confusion tolerance, but still far from the true intersection point. In order to force the intersection algorithm to continue the iteration process until a correct point is found on the tangent objects, the tolerance of intersection must be smaller than the tolerance of confusion. On the other hand, the tolerance of intersection must be large enough to minimize the time required by the process to converge to a solution. The tolerance of intersection is equal to : Precision::Confusion() / 100. (that is, 1.e-9). | |
| static constexpr double | Approximation () |
| Returns the precision value in real space, frequently used by approximation algorithms. This function provides an acceptable level of precision for an approximation process to define adjustment limits. The tolerance of approximation is designed to ensure an acceptable computation time when performing an approximation process. That is why the tolerance of approximation is greater than the tolerance of confusion. The tolerance of approximation is equal to : Precision::Confusion() * 10. (that is, 1.e-6). You may use a smaller tolerance in an approximation algorithm, but this option might be costly. | |
| static constexpr double | Parametric (const double P, const double T) |
| Convert a real space precision to a parametric space precision. <T> is the mean value of the length of the tangent of the curve or the surface. | |
| static constexpr double | PConfusion (const double T) |
| Returns a precision value in parametric space, which may be used : | |
| static constexpr double | SquarePConfusion () |
| Returns square of PConfusion. Created for speed and convenience. | |
| static constexpr double | PIntersection (const double T) |
| Returns a precision value in parametric space, which may be used by intersection algorithms, to decide that a solution is reached. The purpose of this function is to provide an acceptable level of precision in parametric space, for an intersection process to define the adjustment limits. The parametric tolerance of intersection is designed to give a mean value in relation with the dimension of the curve or the surface. It considers that a variation of parameter equal to 1. along a curve (or an isoparametric curve of a surface) generates a segment whose length is equal to 100. (default value), or T. The parametric tolerance of intersection is equal to : | |
| static constexpr double | PApproximation (const double T) |
| Returns a precision value in parametric space, which may be used by approximation algorithms. The purpose of this function is to provide an acceptable level of precision in parametric space, for an approximation process to define the adjustment limits. The parametric tolerance of approximation is designed to give a mean value in relation with the dimension of the curve or the surface. It considers that a variation of parameter equal to 1. along a curve (or an isoparametric curve of a surface) generates a segment whose length is equal to 100. (default value), or T. The parametric tolerance of intersection is equal to : | |
| static constexpr double | Parametric (const double P) |
| Convert a real space precision to a parametric space precision on a default curve. | |
| static constexpr double | PConfusion () |
| Used to test distances in parametric space on a default curve. | |
| static constexpr double | PIntersection () |
| Used for Intersections in parametric space on a default curve. | |
| static constexpr double | PApproximation () |
| Used for Approximations in parametric space on a default curve. | |
| static bool | IsInfinite (const double R) |
| Returns True if R may be considered as an infinite number. Currently std::abs(R) > 1e100. | |
| static constexpr bool | IsPositiveInfinite (const double R) |
| Returns True if R may be considered as a positive infinite number. Currently R > 1e100. | |
| static constexpr bool | IsNegativeInfinite (const double R) |
| Returns True if R may be considered as a negative infinite number. Currently R < -1e100. | |
| static constexpr double | Infinite () |
| Returns a big number that can be considered as infinite. Use -Infinite() for a negative big number. | |
The Precision package offers a set of functions defining precision criteria for use in conventional situations when comparing two numbers. Generalities It is not advisable to use floating number equality. Instead, the difference between numbers must be compared with a given precision, i.e. : double x1, x2 ; x1 = ... x2 = ... If ( x1 == x2 ) ... should not be used and must be written as indicated below: double x1, x2 ; double Precision = ... x1 = ... x2 = ... If ( Abs ( x1 - x2 ) < Precision ) ... Likewise, when ordering floating numbers, you must take the following into account : double x1, x2 ; double Precision = ... x1 = ... ! a large number x2 = ... ! another large number If ( x1 < x2 - Precision ) ... is incorrect when x1 and x2 are large numbers ; it is better to write : double x1, x2 ; double Precision = ... x1 = ... ! a large number x2 = ... ! another large number If ( x2 - x1 > Precision ) ... Precision in Cas.Cade Generally speaking, the precision criterion is not implicit in Cas.Cade. Low-level geometric algorithms accept precision criteria as arguments. As a rule, they should not refer directly to the precision criteria provided by the Precision package. On the other hand, high-level modeling algorithms have to provide the low-level geometric algorithms that they call, with a precision criteria. One way of doing this is to use the above precision criteria. Alternatively, the high-level algorithms can have their own system for precision management. For example, the Topology Data Structure stores precision criteria for each elementary shape (as a vertex, an edge or a face). When a new topological object is constructed, the precision criteria are taken from those provided by the Precision package, and stored in the related data structure. Later, a topological algorithm which analyses these objects will work with the values stored in the data structure. Also, if this algorithm is to build a new topological object, from these precision criteria, it will compute a new precision criterion for the new topological object, and write it into the data structure of the new topological object. The different precision criteria offered by the Precision package, cover the most common requirements of geometric algorithms, such as intersections, approximations, and so on. The choice of precision depends on the algorithm and on the geometric space. The geometric space may be :
Returns the recommended precision value when checking the equality of two angles (given in radians). double Angle1 = ... , Angle2 = ... ; If ( std::abs( Angle2 - Angle1 ) < Precision::Angular() ) ... The tolerance of angular equality may be used to check the parallelism of two vectors : gp_Vec V1, V2 ; V1 = ... V2 = ... If ( V1.IsParallel (V2, Precision::Angular() ) ) ... The tolerance of angular equality is equal to 1.e-12. Note : The tolerance of angular equality can be used when working with scalar products or cross products since sines and angles are equivalent for small angles. Therefore, in order to check whether two unit vectors are perpendicular : gp_Dir D1, D2 ; D1 = ... D2 = ... you can use : If ( std::abs( D1.D2 ) < Precision::Angular() ) ... (although the function IsNormal does exist).
Returns the precision value in real space, frequently used by approximation algorithms. This function provides an acceptable level of precision for an approximation process to define adjustment limits. The tolerance of approximation is designed to ensure an acceptable computation time when performing an approximation process. That is why the tolerance of approximation is greater than the tolerance of confusion. The tolerance of approximation is equal to : Precision::Confusion() * 10. (that is, 1.e-6). You may use a smaller tolerance in an approximation algorithm, but this option might be costly.
Returns a precision value at machine epsilon level, used for low-level numerical computations and floating-point comparisons. Unlike the geometric tolerances (Confusion, Intersection, Approximation) which are application-level values for modeling operations, this value represents the fundamental limit of floating-point arithmetic precision.
Typical use cases include:
The computational tolerance is equal to DBL_EPSILON (approximately 2.22e-16), which is the smallest positive value such that 1.0 + eps != 1.0 in double precision floating-point arithmetic. This is the fundamental machine epsilon for double (double) type.
Note: This value should NOT be used for geometric comparisons. Use Precision::Confusion() for comparing geometric distances, Precision::Angular() for angles, etc.
Returns the recommended precision value when checking coincidence of two points in real space. The tolerance of confusion is used for testing a 3D distance :
Returns a big number that can be considered as infinite. Use -Infinite() for a negative big number.
Returns the precision value in real space, frequently used by intersection algorithms to decide that a solution is reached. This function provides an acceptable level of precision for an intersection process to define the adjustment limits. The tolerance of intersection is designed to ensure that a point computed by an iterative algorithm as the intersection between two curves is indeed on the intersection. It is obvious that two tangent curves are close to each other, on a large distance. An iterative algorithm of intersection may find points on these curves within the scope of the confusion tolerance, but still far from the true intersection point. In order to force the intersection algorithm to continue the iteration process until a correct point is found on the tangent objects, the tolerance of intersection must be smaller than the tolerance of confusion. On the other hand, the tolerance of intersection must be large enough to minimize the time required by the process to converge to a solution. The tolerance of intersection is equal to : Precision::Confusion() / 100. (that is, 1.e-9).
Returns True if R may be considered as an infinite number. Currently std::abs(R) > 1e100.
Returns True if R may be considered as a negative infinite number. Currently R < -1e100.
Returns True if R may be considered as a positive infinite number. Currently R > 1e100.
Used for Approximations in parametric space on a default curve.
This is Precision::Parametric(Precision::Approximation())
Returns a precision value in parametric space, which may be used by approximation algorithms. The purpose of this function is to provide an acceptable level of precision in parametric space, for an approximation process to define the adjustment limits. The parametric tolerance of approximation is designed to give a mean value in relation with the dimension of the curve or the surface. It considers that a variation of parameter equal to 1. along a curve (or an isoparametric curve of a surface) generates a segment whose length is equal to 100. (default value), or T. The parametric tolerance of intersection is equal to :
Convert a real space precision to a parametric space precision on a default curve.
Value is Parametric(P,1.e+2)
|
inlinestaticconstexpr |
Convert a real space precision to a parametric space precision. <T> is the mean value of the length of the tangent of the curve or the surface.
Value is P / T
Used to test distances in parametric space on a default curve.
This is Precision::Parametric(Precision::Confusion())
Returns a precision value in parametric space, which may be used :
Used for Intersections in parametric space on a default curve.
This is Precision::Parametric(Precision::Intersection())
Returns a precision value in parametric space, which may be used by intersection algorithms, to decide that a solution is reached. The purpose of this function is to provide an acceptable level of precision in parametric space, for an intersection process to define the adjustment limits. The parametric tolerance of intersection is designed to give a mean value in relation with the dimension of the curve or the surface. It considers that a variation of parameter equal to 1. along a curve (or an isoparametric curve of a surface) generates a segment whose length is equal to 100. (default value), or T. The parametric tolerance of intersection is equal to :
Returns square of Computational. Created for speed and convenience when comparing squared values.
Returns square of Confusion. Created for speed and convenience.
Returns square of PConfusion. Created for speed and convenience.