Re: [eigen] about Transform API

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Wed, Aug 27, 2008 at 4:47 AM, Gael Guennebaud
<gael.guennebaud@xxxxxxxxx> wrote:
>
> For instance if you want to concatenate a scale S to a transformation
> T you would write:
>
> paper:  T' = T * S
> or
> paper:  T' =  S * T
>
> while in Eigen we currently have to write:
>
> eigen:   T = T.scale(Vector3f(sx,sy,sz));
> or
> eigen:   T = T.prescale(Vector3f(sx,sy,sz));

I've not yet used scaling in eigen.  I presume that the Vector is used to
initialize a diagonal matrix that is multiplied in (or perhaps you
use a more efficient algorithm to scale the transform).

> What about doing something similar to what I did with rotations and
> overloading the correct *= and * operators such that you could write:
>
> eigen:   T = T * Scale3f(sx,sy,sz);
> eigen:   T *= Scale3f(sx,sy,sz);
> or
> eigen:   T = Scale3f(sx,sy,sz) * T;

Presumably, Scale3f(sx,sy,sz) would construct a 3x3 diagonal matrix.
The scale constructor above seems much prettier to me than initializing
with a Vector, but I suppose that you would need a Vector initialization
of Scale for the arbitrary NxN case.  (As you have probably noticed, I
prefer to instantiate a Vector only if it is really a vector. :^)

> then if you want to express:
>
> paper: T = S * R * L;
>
> (where L is a translation)
> you could write:
>
> eigen:  T = Scale3f(..) * RotationType(....) * Translation3f(...);
> (with RotationType in {Quaternion, Matrix, AngleAxis, Rotation2D } )

So Translation3f() constructs a 4x4, and the first multiplication
(between the Scale and the Rotation) is between a pair of 3x3s, right?

> instead of the current:
>
> eigen:  T.setIdentity();
> eigen:  T.scale(...);
> eigen:  T.rotate(...);
> eigen:  T.translate(...);
>
> ok, actually the rotate, scale and translate methods return a reference to
> T, so currently you can still write:
>
> eigen:  T.setIdentity();
> eigen:  T.scale(...).rotate(...).translate(...);
>
> that is not too bad in that case, but think about "T = R1 * L * T * R2"
> which involves "pre*" versions of the methods:
>
> eigen:  T.pretranslate(L).prerotate(R1).rotate(R2);

Yuck.

> IMHO it's quite confusing because it does not give you the idea of the
> transformation order: "R1 * L * T * R2".

Right.

> Also, perhaps we can keep both API ?

Why not?

> that's all folk, what do you think ?

I think that it is a beautiful idea, at least in terms of the API.

-- 
Thomas E. Vaughan

There are only two kinds of people; those who accept dogma and know it,
and those who accept dogma and don't know it. - G.K. Chesterton



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/