| 1 |
h1. Geometric Primitives |
| 2 |
|
| 3 |
What good is a geometry library without geometric primitives? By this |
| 4 |
I mean the very basic stuff, Points/Vectors, Matrices, etc. |
| 5 |
|
| 6 |
2geom's primitives are descendant from libNR's geometric primitives. |
| 7 |
They have been modified quite a bit since that initial import. |
| 8 |
|
| 9 |
h2. Point |
| 10 |
|
| 11 |
!media/point.png! |
| 12 |
|
| 13 |
The mathematical concepts of points and vectors are merged into the |
| 14 |
2geom class called *Point*. See Appendix A for a further |
| 15 |
discussion of this decision. |
| 16 |
|
| 17 |
Point may be interpreted as a D2<double> with some additional operations. |
| 18 |
|
| 19 |
(TODO: document these ops.) |
| 20 |
|
| 21 |
\section{Transformations} |
| 22 |
|
| 23 |
Affine transformations are either represented with a canonical 6 |
| 24 |
element matrix, or special forms. |
| 25 |
|
| 26 |
\subsection{Scale} |
| 27 |
|
| 28 |
\includegraphics[height=50mm]{media/scale.png} |
| 29 |
|
| 30 |
A \code{Scale} transformation stores a vector representing a scaling |
| 31 |
transformation. |
| 32 |
|
| 33 |
\subsection{Rotate} |
| 34 |
|
| 35 |
\includegraphics[height=50mm]{media/rotate.png} |
| 36 |
|
| 37 |
A \code{Rotate} transformation uses a vector(\code{Point}) to store |
| 38 |
a rotation about the origin. |
| 39 |
|
| 40 |
In correspondence with mathematical convention (y increasing upwards), |
| 41 |
0 degrees is encoded as a vector pointing along the x axis, and positive |
| 42 |
angles indicate anticlockwise rotation. So, for example, a vector along |
| 43 |
the y axis would encode a 90 degree anticlockwise rotation of 90 degrees. |
| 44 |
|
| 45 |
In the case that the computer convention of y increasing downwards, |
| 46 |
the \verb}Rotate} transformation works essentially the same, except |
| 47 |
that positive angles indicate clockwise rotation. |
| 48 |
|
| 49 |
\subsection{Translate} |
| 50 |
|
| 51 |
\includegraphics[height=70mm]{media/translate.png} |
| 52 |
|
| 53 |
A \code{Translate} transformation is a simple vector(\code{Point}) |
| 54 |
which stores an offset. |
| 55 |
|
| 56 |
\subsection{Matrix} |
| 57 |
|
| 58 |
\includegraphics[height=70mm]{media/matrix.png} |
| 59 |
|
| 60 |
A \code{Matrix} is a general affine transform. Code is provided for |
| 61 |
various decompositions, constructions, and manipulations. A |
| 62 |
\code{Matrix} is composed of 6 coordinates, essentially storing the |
| 63 |
x axis, y axis, and offset of the transformation. A detailed |
| 64 |
explanation for matrices is given in Appendix B. |
| 65 |
|