Navigation: Up, Table of Contents, Bibliography, Index, Title Page

Fixed precision numbers (CGAL_Fixed_precision_nt)

The class CGAL_Fixed_precision_nt provides 24 bits number in fixed point representation. Basically these numbers are integers in the range [-224,224] with a multiplying factor 2b. The multiplying factor 2b has to be initialized by the user before the construction of the first CGAL_Fixed_precision_nt.

The interest of such a number type is that geometric predicates can be overloaded to get exact and very efficient predicates. The drawback is that any CGAL_Fixed_precision_nt is rounded to the nearest multiple of 2b, which yields to a very poor arithmetic. The idea is to not use the arithmetic on CGAL_Fixed_precision_nt but only the specialized predicates.

Creation

#include <CGAL/Fixed_precision_nt.h>

CGAL_Fixed_precision_nt fvar ( double);
Initialization of a variable. The variable is rounded to the nearest legal fixed number (i.e. a multiple of 2b= CGAL_Fixed_precision_nt::unit_value()

CGAL_Fixed_precision_nt fvar;
Declaration.

CGAL_Fixed_precision_nt fvar ( fval);
Declaration and initialization.

CGAL_Fixed_precision_nt fvar ( i);
Declaration and initialization with an integer.

Operations

The comparison operations ==, !=, <, >, <=, and >= are all available.

CGAL_Fixed_precision_nt &
fvar = fval Assignment.
bool CGAL_is_valid ( fval)
In case of overflow or division by 0, numbers becomes invalid. If the precision is changed by usage of CGAL_Fixed_precision_nt::init(), already existing numbers may became invalid if they are non longer multiple of 2b.
bool CGAL_is_finite ( fval)
CGAL_Fixed_precision_ntdo not implement infinite numbers. CGAL_is_finite is identical to CGAL_is_valid.
CGAL_Fixed_precision_nt
fval1 + fval2 rounds the result to nearest legal Fixed.
CGAL_Fixed_precision_nt
fval1 - fval2 rounds the result to nearest legal Fixed.
CGAL_Fixed_precision_nt
fval1 * fval2 rounds the result to nearest legal Fixed. Overflow is possible.
CGAL_Fixed_precision_nt
- fval rounds the result to nearest legal Fixed.
CGAL_Fixed_precision_nt
fvar += f rounds the result to nearest legal Fixed.
CGAL_Fixed_precision_nt
fvar -= f rounds the result to nearest legal Fixed.
CGAL_Fixed_precision_nt
fvar *= f rounds the result to nearest legal Fixed. Overflow is possible.
CGAL_Fixed_precision_nt
fvar /= f rounds the result to nearest legal Fixed. Overflow is possible.
CGAL_Fixed_precision_nt
fval1 / fval2 rounds the result to nearest legal Fixed. Overflow is possible.
double CGAL_to_double ( fval)
casts to double.

Precision initialization

As mentioned before, the CGAL_Fixed_precision_nt numbers works in an interval [-224+b,224+b] of multiples of 2b, this number b as to be defined before all use of CGAL_Fixed_precision_nt.

static bool CGAL_Fixed_precision_nt::init ( float B)
B is an upper bound on the data, b is the smallest integer such that |B|<=2b. The result of the function is false if initialization was already done, in that case already existing CGAL_Fixed_precision_nt may became invalid.
static float CGAL_Fixed_precision_nt::unit_value ()
returns 2b.
static float CGAL_Fixed_precision_nt::upper_bound ()
returns 224+b.

Perturbation scheme

CGAL_Fixed_precision_nt implements perturbation scheme as described by Alliez, Devillers and Snoeyink [ADS97]. The perturbation mode can be activate or deactivate for different kinds of perturbations. The default mode is no perturbation.

static void CGAL_Fixed_precision_nt::perturb_incircle ()
Activate. Incircle test of 4 cocircular points answers degenerate only if the 4 points are colinear.
static void CGAL_Fixed_precision_nt::unperturb_incircle ()
Deactivate
static bool CGAL_Fixed_precision_nt::is_perturbed_incircle ()
returns current mode
static void CGAL_Fixed_precision_nt::perturb_insphere ()
Activate. Insphere test of 5 cospherical points answers degenerate only if the 5 points are coplanar.
static void CGAL_Fixed_precision_nt::unperturb_insphere ()
Deactivate
static bool CGAL_Fixed_precision_nt::is_perturbed_insphere ()
returns current mode

Geometric predicates

Through overloading mechanisms, functions such that CGAL_orientation for CGAL_Point_2<CGAL_Cartesian< CGAL_Fixed_precision_nt> > will correctly call the function below.

CGAL_Orientation CGAL_orientationC2 ( x0, y0, x1, y1, x2, y2)
CGAL_Oriented_side
CGAL_side_of_oriented_circleC2 ( x0,
y0,
x1,
y1,
x2,
y2,
x3,
y3)
Perturbation mode can be activated.
CGAL_Orientation
CGAL_orientationC3 ( x0,
y0,
z0,
x1,
y1,
z1,
x2,
y2,
z2,
x3,
y3,
z3)
CGAL_Oriented_side
CGAL_side_of_oriented_sphereC3 ( x0,
y0,
z0,
x1,
y1,
z1,
x2,
y2,
z2,
x3,
y3,
z3,
x4,
y4,
z4)
Perturbation mode can be activated.


Next: Class declaration of CGAL_Interval_nt
Navigation: Up, Table of Contents, Bibliography, Index, Title Page
The CGAL Project. 22 January 1999.