This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 999

Summary: Product: AlignedBox Volume/Empty Test Disagree Eigen Christopher J. Hanks Geometry Nobody RESOLVED FIXED Wrong Result chtz, gael.guennebaud, hauke.heibel, jacob.benoit.1 Normal Documentation 3.3 (current stable) All All

 Christopher J. Hanks 2015-04-16 21:46:40 UTC ```In an AlignedBox structure, two boxes can be fashioned such that their intersection yields a new box with (::volume() > 0) that (::isEmpty() == true). #include #include int main() { Eigen::AlignedBox b0( Eigen::Vector3d(-1, -1, -1), Eigen::Vector3d( 0, 0, 0)); Eigen::AlignedBox b1( Eigen::Vector3d(-1, 2, 2), Eigen::Vector3d( 0, 0, 0)); std::cerr << std::boolalpha << (b1.intersection(b0)).volume() << "\n" << (b1.intersection(b0)).isEmpty() << "\n"; // Prints out: // 4 // true return 0; }``` Gael Guennebaud 2015-04-17 09:55:43 UTC ```Indeed. Actually this problem is more general as many other methods fail if along at least one dimension the minimum entry is greater than the maximum. They include: sizes(), volume(), diagonal() -> all based on sizes(). shall we clamp negative sizes to zero? sample() -> it currently returns the min coeff, but that's undocumented squaredExteriorDistance() -> what should be the behavior? shall we use the min coeff as for sample?``` Christoph Hertzberg 2015-04-17 11:15:44 UTC ```You also have b1.volume()==4 and b1.isEmpty(), so b1 is already ill-formed. I think the problem is that it is not really specified/documented how Eigen handles ill-formed boxes -- also it is not evident that the _min, _max constructor does not automatically make a valid box from the passed corner points.``` Christoph Hertzberg 2015-04-20 19:06:12 UTC ```I would vote for just improving the documentation (mostly saying that the result of any method is undefined for empty boxes), but keep the current behavior here. I don't think that volume()>0 should be considered in any way equivalent to !isEmpty(). E.g., there is also the case of a one-point box, which has volume 0, but is not empty. We may consider adding a constructor which automatically takes min and max of the input vectors, if that is required a lot. Making this the default probably breaks existing code (not sure, if constructing an explicit empty box has any use-case, though)``` Christoph Hertzberg 2015-04-30 17:36:08 UTC ```I clarified in the documentation that empty boxes can lead to undefined behavior: https://bitbucket.org/eigen/eigen/commits/cf8979c54 https://bitbucket.org/eigen/eigen/commits/16d9b3559``` Nobody 2019-12-04 14:31:55 UTC ```-- GitLab Migration Automatic Message -- This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity. You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/999.```