999
2015-04-16 21:46:40 +0000
AlignedBox Volume/Empty Test Disagree
2019-12-04 14:31:55 +0000
1
1
1
Unclassified
Eigen
Geometry
3.3 (current stable)
All
All
RESOLVED
FIXED
Documentation
Normal
Wrong Result
---
1
web
eigen.nobody
chtz
gael.guennebaud
hauke.heibel
jacob.benoit.1
oldest_to_newest
4587
0
web
2015-04-16 21:46:40 +0000
In an AlignedBox<double 3> structure, two boxes can be fashioned such that their intersection yields a new box with (::volume() > 0) that (::isEmpty() == true).
#include <iostream>
#include <Eigen/Eigen>
int
main()
{
Eigen::AlignedBox<double, 3> b0(
Eigen::Vector3d(-1, -1, -1),
Eigen::Vector3d( 0, 0, 0));
Eigen::AlignedBox<double, 3> 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;
}
4589
1
gael.guennebaud
2015-04-17 09:55:43 +0000
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?
4590
2
chtz
2015-04-17 11:15:44 +0000
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.
4596
3
chtz
2015-04-20 19:06:12 +0000
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)
4658
4
chtz
2015-04-30 17:36:08 +0000
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
9443
5
eigen.nobody
2019-12-04 14:31:55 +0000
-- 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.