Boost logo

Boost :

From: Matthias Troyer (troyer_at_[hidden])
Date: 2006-08-26 04:20:42


On Aug 24, 2006, at 8:02 PM, Andy Little wrote:

>
> "Matthias Troyer" <troyer_at_[hidden]> wrote
>> Andy Little wrote
> <...>
>
>>> For matrices my tests have been limited to homogeneous
>>> transformation matrices.
>>> In this case the matrix elements for a *simple/obvious*
>>> implementation of a
>>> matrix for a physical quantity are comprised of various types,
>>> comprising of the
>>> quantity type, the reciprocal of the quantity and numeric types. It
>>> may be
>>> possible to somehow 'tag' a numeric matrix as a quantity matrix,
>>> but I havent
>>> invetigated that.
>>
>> Just use a quantity as value type? What's the problem with that?
>
> Assume a 2D homogeneous transform matrix intended to transform 2d
> points. With 9
> elements it is possible for the matrix to contain up to 9 separate
> types T0 - T9
>
> ( T1 , T2, T3)
> ( T4, T5, T6 )
> ( T7, T8, T9)
>
> In the transform matrix T1, T2, T4 and T5 are concerned with
> rotation. IOW to
> rotate a point through an angle alpha
>
> (cos(alpha), sin(alpha), T3
> (-sin(alpha), cos(alpha), T6)
> ( T7, T8, T9)
>
> Therefore T1, T2, T4, T5 must be numeric.
>
> T7 and T8 represent translation. To translate a homogeneous point
> [ X Y h],
> assuming h is a numeric and X and Y are some quantity, T7 and T8
> must have the
> dimensionally equivalent quantity type ( but not necesarily same
> unit) as X and
> Y. (In fact in this case T3 and T6 have the reciprocal quantity
> type of X and
> Y and T9 is always a numeric representing scaling)

Wait a moment, matrices are representations of linear operators in a
vector space Let us first consider what that vector space here is.
For the transformation matrices you mention we have vectors (x, y, 1)
that we want to transform. We can choose, as is usual, the same
units for the three components. If we now have a linear operator from
this vector space to itself, as we have here, then all entries in the
matrix must be pure numbers, since we do not change any units. And
indeed, if one looks at the matrix you propose than for translations
+ rotations it actually is

(cos(alpha), sin(alpha), dx )
(-sin(alpha), cos(alpha), dy)
(0, 0, 1)

all entries are pure numbers, and the translations dx and dy are
given in terms of the unit chosen for the 1 in the vector. This is
actually just what you propose as second option:

> Another alternative is to make all the elements of the matrix
> numeric. In this
> case h in the homogeneous coordinate [X Y h] would have the same
> type as X and
> Y.

But I disagree with your next statement:

> That isnt as neat though as you have then lost the unit information
> in T7 and
> T8 regarding the translation and applying the matrix to a point in
> different
> units would give different results.

No, you have not lost the unit information, since it is encoded in
the vector type. And indeed applying a matrix to different vector
spaces (e.g. points with different units), should actually give
different results!

> I hope I have demonstrated some of the issues in the above example.
> However I
> have only limited my experiments to transform matrices. I should
> probably look
> at other matrix calculations to see what happens in other cases too.

 From my 20 years of experience with matrix calculations I have not
seen a case yet where different value types are required for
different matrix elements - this actually contradicts the definition
f a matrix, where all elements are taken from the same number field.

Matthias


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk