# Boost :

From: Andy Little (andy_at_[hidden])
Date: 2005-06-02 10:23:44

"Hubert Holin" <Hubert.Holin_at_[hidden]> wrote

> The fact that they would be fast would be icing on the cake, not
> the cake itself, as it were. What is most needed IMHO is a clear and
> rich set of links between the various elements of that collection
> (complex <-> plane (vector) rotation; rotation <-> geometric elements of
> the rotation (when meaningful); 2D, 3D, 4D points;...).

Addressing the issue of points, affine space and so on. There has been some
discussion on the list regarding whether points and vectors should be
distinguished as types, with allowed operations on points being restricted to
addition of a vector, and subtration of two points resulting in a vector.
However in some contexts addition and multiplication of points is meaningful.

eg to find the point 1/3 rd way from the start of line(A , B) one could
calculate 2/3 *A +1/3 * B.

It is only in a context such as the above that addition and multiplication of
points has meaning. It is possible to construct compile time structures using
eg compile time rational numbers and enforcing conversion of the result to a
point only where the rational sums to 1, however it would restrict the
calculations to points where the weights are known at compile time.

It is for this reason that I prefer to make no distinction between points and
vectors and am happy to represent coordinates as vectors, which allows use of
transform matrices. One can call them position-vectors.

--------------

Rotation around an arbitrary axis is an example of a coordinate system
transform, which can be represented by means of a matrix. I appreciate that a
quaternion may be more efficient but I think it is limited to only rotation and
scaling. Matrix transformations should be implemented first because they are
generic.

-----------------

In my experiments with physical quantities I found that it is possible (of
course) to make a matrix conform to dimensional analysis. In terms of a 3D
matrix for a type of dimension D the signature for a row-column matrix

looks as follows (Forgive me for pushing the typeof library)
typedef BOOST_TYPEOF( D() / D()) dimensionless;
typedef BOOST_TYPEOF( 1 / D()) reciprocal;
typedef D identity;

The types in RC format look like so:

| dimensionless, dimensionless, dimensionless, reciprocal, |
| dimensionless, dimensionless, dimensionless, reciprocal, |
| dimensionless, dimensionless, dimensionless, reciprocal, |
| D, D, D, dimensionless |

Note that this can actually make the matrix more comprehensible. For instance if
D is a length type eg millimeters then The three D's in [3,0],[3,1],and [3,2]
represent the x,y,z components of a translation in millimeters. Further it is
not possible to accidentally multiply matrices of transposed types.

Similarly a homogeneous coordinate looks like so :
|dimensionless, dimensionless, dimensionless, reciprocal |

I bring this up because perhaps you should consider this if you wish to make the
matrices truly generic.( The dimensionless and reciprocal types are functions of
the matrix calculations rather than a physical quantities library.)OTOH maybe
you would need to restrict value-types to numeric types where both these
functions are identities.

regards
Andy Little