| 1 |
%-------------------------------------------------------------------- |
| 2 |
\section{Numerical Tolerance} |
| 3 |
\label{sec:numerical_tolerance} |
| 4 |
|
| 5 |
\subsection{Floating-Point Arithmetic} |
| 6 |
|
| 7 |
All computations in \tkzNamePack{tkz-elements} are performed using |
| 8 |
floating-point arithmetic. |
| 9 |
As a consequence, exact comparisons between real numbers are unreliable. |
| 10 |
|
| 11 |
For example, a point theoretically lying on a line may produce a |
| 12 |
very small non-zero value due to rounding errors. |
| 13 |
|
| 14 |
\subsection{Global Tolerance: \code{tkz.epsilon}} |
| 15 |
|
| 16 |
To ensure numerical robustness, \tkzNamePack{tkz-elements} |
| 17 |
uses a global tolerance parameter: |
| 18 |
|
| 19 |
|
| 20 |
\verb|tkz.epsilon = 1e-10| |
| 21 |
|
| 22 |
|
| 23 |
This value defines the admissible numerical error in geometric tests |
| 24 |
(collinearity, incidence, equality of distances, etc.). |
| 25 |
|
| 26 |
\medskip |
| 27 |
By default, this tolerance is set to a small positive value. |
| 28 |
It can be adjusted by advanced users if needed. |
| 29 |
|
| 30 |
\subsection{Usage in Position Tests} |
| 31 |
|
| 32 |
All membership and position tests are \emph{EPS-aware}. |
| 33 |
When a method accepts an optional argument \code{EPS}, the following rule applies: |
| 34 |
|
| 35 |
\begin{itemize} |
| 36 |
\item If \code{EPS} is provided, it overrides the global tolerance. |
| 37 |
\item Otherwise, \code{tkz.epsilon} is used. |
| 38 |
\end{itemize} |
| 39 |
|
| 40 |
This design ensures consistency across all geometric objects. |