问题
I am currently looking into Eigen::Isometry3f
, defined as
typedef Transform<float,3,Isometry> Isometry3f;
.
Therewith i cannot, for example, assign an Affine3f
to that Isometry3f
, which is good to keep the isometry intact. (The reason is, that Mode
is checked in the assignment operator of Transform
.)
I can however - via the Transform::operator(...)
, which shortcuts to Transform::m_matrix(...)
- do
Eigen::Isometry3f iso;
iso.setIdentity();
iso(1, 1) = 2; //works (but should not ?!)
and thus destroy the isometry.
Q1:
Shouldn't Transform::operator(...)
be disallowed or at least issue a warning? If you really want to mess up you could still use Transform.matrix()(1,1) = 2
...
Q2: Are there other pitfalls where i could accidentally destroy my isometry?
Q3:
If there are other pitfalls: what is the intention of Mode==Isometry
? Is it not to ensure closedness/safety?
回答1:
The main purpose of Mode==Isometry
is to improve the speed of some operations, like inversion, or extraction of rotation part. It essentially says "I, the user, guaranty to Eigen that the underlying matrix represent an isometry". So it is the responsibility of the user to no shoot itself. You can also break an initial isometry by replacing the linear part with a bad matrix:
iso.linear() = Matrix3f::Random();
Checking for isometry is not cheap at all, so adding checks everywhere would break the initial purpose. Perhaps, adding a bool Transform::checkIsometry()
would help tracking issues in user code, but this is out-of the scope of SO.
来源:https://stackoverflow.com/questions/46176533/how-to-ensure-eigen-isometry-stays-isometric