Points
don't always have to remain in the same place. There are
various ways of moving or transforming them:
shift
, so I call it "shifting".
class Point
has several member functions
for applying these affine transformations1
to a Point
.
Most of the arguments to these functions are of
type real
. As you may know, there is no such data type in C++
.
I have defined real
using typedef
to be either
float
or double
, depending on the value of a preprocessor
switch for conditional compilation.2
3DLDF uses many real
values and I wanted to be able to
change the precision used by making one change (in the file
pspglb.web
) rather than having to examine all the places in the
program where float
or double
are used. Unfortunately,
setting real
to double
currently doesn't work.
Affine transformations are operations that have the property that parallelity of lines is maintained. That is, if two lines (each determined by two points) are parallel before the transformation, they will also be parallel after the transformation. Affine transformations are discussed in many books about computer graphics and geometry. For 3DLDF, I've mostly used Jones, Computer Graphics through Key Mathematics and Salomon, Computer Graphics and Geometric Modeling.
I try to avoid the use of preprocessor macros as much as possible, for the reasons given by Stroustrup in the The C++ Programming Language, section 7.8, pp. 160--163, and Design and Evolution of C++ , Chapter 18, pp. 423--426. However, conditional compilation is one of the tasks that only the preprocessor can perform.