How to ensure Eigen isometry stays isometric?

冷暖自知 提交于 2020-01-03 16:58:59

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!