Re: [eigen] RotationBase times DiagonalMatrix

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


On 24.09.2011 13:38, Hauke Heibel wrote:
OTOH, one might argue that with such an implicit conversion the memory
requirements increase from Dim to 2*(Dim+1) for translations as well
as scaling types.

I guess you meant Dim*(Dim+1). Besides the memory maybe also important is the increased number of flops: 2n²+n for Transform, vs. n for Translate/Scale.

Maybe introducing a

  template<class Derived>
  class TransformBase;

is the solution. This would describe all Transformations -- affine or pure linear. Then one can pass arbitrary Transformations as templated class, ensuring best performance and avoiding type conversions, but still the current Transform class could be constructed from anything which inherits from TransformBase. If then someone does:

  Transform a = Translation(...);

he'll get a performance/memory penalty, but that's exactly the same for

  Matrix<..> m = Diagonal<...>(...);

I.e. one can decide oneself, if one knows that a is always a translation, or want to permit things such as:

  Transform a;
  if(...)
    a = Translation(...);
  else
    a = Rotation(...);

etc...


We could add a non explicit one from DiagonalMatrix then.

And here is the only point where I am not sure. In my eyes the only
reason is the increased memory requirement but that's the same as for
Translations. Following the *is a* reasoning of Christoph, the
conversion is fine as long the Transform is not an Isometry and I
think we could prevent this conversion once again with a
static_assert.

As I said before, if you allow

  Transform a;
  a = Diagonal(...);

I see no reason, why implicit conversions should be prohibited.

Christoph

--
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.051
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: (+49) 421-218-64252
----------------------------------------------



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