mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Fix alignedbox 32-bit precision test failure.
The current `test/geo_alignedbox` tests fail on 32-bit arm due to small floating-point errors. In particular, the following is not guaranteed to hold: ``` IsometryTransform identity = IsometryTransform::Identity(); BoxType transformedC; transformedC.extend(c.transformed(identity)); VERIFY(transformedC.contains(c)); ``` since `c.transformed(identity)` is ever-so-slightly different from `c`. Instead, we replace this test with one that checks an identity transform is within floating-point precision of `c`. Also updated the condition on `AlignedBox::transform(...)` to only accept `Affine`, `AffineCompact`, and `Isometry` modes explicitly. Otherwise, invalid combinations of modes would also incorrectly pass the assertion.
This commit is contained in:
parent
30960d485e
commit
d5a0d89491
@ -338,8 +338,8 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
|
|||||||
template<int Mode, int Options>
|
template<int Mode, int Options>
|
||||||
EIGEN_DEVICE_FUNC inline void transform(const Transform<Scalar, AmbientDimAtCompileTime, Mode, Options>& transform)
|
EIGEN_DEVICE_FUNC inline void transform(const Transform<Scalar, AmbientDimAtCompileTime, Mode, Options>& transform)
|
||||||
{
|
{
|
||||||
// Projective transform is not (yet) supported
|
// Only Affine and Isometry transforms are currently supported.
|
||||||
EIGEN_STATIC_ASSERT(Mode != Projective, THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS);
|
EIGEN_STATIC_ASSERT(Mode == Affine || Mode == AffineCompact || Mode == Isometry, THIS_METHOD_IS_ONLY_FOR_SPECIFIC_TRANSFORMATIONS);
|
||||||
|
|
||||||
// Method adapted from FCL src/shape/geometric_shapes_utility.cpp#computeBV<AABB, Box>(...)
|
// Method adapted from FCL src/shape/geometric_shapes_utility.cpp#computeBV<AABB, Box>(...)
|
||||||
// https://github.com/flexible-collision-library/fcl/blob/fcl-0.4/src/shape/geometric_shapes_utility.cpp#L292
|
// https://github.com/flexible-collision-library/fcl/blob/fcl-0.4/src/shape/geometric_shapes_utility.cpp#L292
|
||||||
|
@ -150,11 +150,9 @@ template<typename BoxType> void alignedboxTranslatable(const BoxType& _box)
|
|||||||
VERIFY_IS_APPROX((c.min)(), UnitX * Scalar(9));
|
VERIFY_IS_APPROX((c.min)(), UnitX * Scalar(9));
|
||||||
VERIFY_IS_APPROX((c.max)(), Ones * Scalar(18) + UnitX * Scalar(9));
|
VERIFY_IS_APPROX((c.max)(), Ones * Scalar(18) + UnitX * Scalar(9));
|
||||||
|
|
||||||
// test for roundoff errors
|
// Check identity transform within numerical precision.
|
||||||
IsometryTransform identity = IsometryTransform::Identity();
|
BoxType transformedC = c.transformed(IsometryTransform::Identity());
|
||||||
BoxType transformedC;
|
VERIFY_IS_APPROX(transformedC, c);
|
||||||
transformedC.extend(c.transformed(identity));
|
|
||||||
VERIFY(transformedC.contains(c));
|
|
||||||
|
|
||||||
for (size_t i = 0; i < 10; ++i)
|
for (size_t i = 0; i < 10; ++i)
|
||||||
{
|
{
|
||||||
@ -335,10 +333,6 @@ template<typename BoxType, typename Rotation> void alignedboxNonIntegralRotatabl
|
|||||||
const Index dim = _box.dim();
|
const Index dim = _box.dim();
|
||||||
const VectorType Zero = VectorType::Zero();
|
const VectorType Zero = VectorType::Zero();
|
||||||
const VectorType Ones = VectorType::Ones();
|
const VectorType Ones = VectorType::Ones();
|
||||||
const VectorType UnitX = VectorType::UnitX();
|
|
||||||
const VectorType UnitY = VectorType::UnitY();
|
|
||||||
// this is vector (0, 0, -1, -1, -1, ...), i.e. with zeros at first and second dimensions
|
|
||||||
const VectorType UnitZ = Ones - UnitX - UnitY;
|
|
||||||
|
|
||||||
VectorType minPoint = -2 * Ones;
|
VectorType minPoint = -2 * Ones;
|
||||||
minPoint[1] = 1;
|
minPoint[1] = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user