11 #include <Eigen/Geometry>
28 template<
typename BoxType>
void alignedbox(
const BoxType& box)
38 const Index dim = box.dim();
43 p1 = VectorType::Random(dim); }
44 RealScalar s1 = internal::random<RealScalar>(0,1);
47 BoxType
b1(VectorType::Random(dim),VectorType::Random(dim));
57 VERIFY(b0.contains(b0.center()));
66 BoxType box1(VectorType::Random(dim));
67 box1.extend(VectorType::Random(dim));
68 BoxType box2(VectorType::Random(dim));
69 box2.extend(VectorType::Random(dim));
71 VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty());
74 BoxType *bp0 =
new BoxType(dim);
75 BoxType *bp1 =
new BoxType(dim);
81 for(
int i=0;
i<10; ++
i )
100 const Index dim = box.dim();
103 BoxType
a(-Ones, Ones);
110 b.translate(translate);
119 IsometryTransform tf = IsometryTransform::Identity();
120 tf.translation() = -translate;
122 BoxType
c =
b.transformed(tf);
136 AffineTransform atf = AffineTransform::Identity();
144 atf = AffineTransform::Identity();
153 BoxType transformedC =
c.transformed(IsometryTransform::Identity());
156 for (
size_t i = 0;
i < 10; ++
i)
162 minCorner[
d] = internal::random<Scalar>(-10,10);
163 maxCorner[
d] = minCorner[
d] + internal::random<Scalar>(0, 10);
166 c = BoxType(minCorner, maxCorner);
168 translate = VectorType::Random();
169 c.translate(translate);
176 template<
typename Scalar,
typename Rotation>
181 template<
typename Scalar,
typename Rotation>
185 template cast<Scalar>();
188 template<
typename Scalar,
typename Rotation>
193 template<
typename Scalar,
typename Rotation>
200 template<
typename Scalar,
typename Rotation>
203 result.block(0, 0, 3, 3) = rotate3DZAxis<Scalar, AngleAxisd>(angle).toRotationMatrix();
207 template <
typename MatrixType>
213 const MatrixType q = rand.householderQr().householderQ();
217 diag(MatrixType::RowsAtCompileTime - 1, MatrixType::ColsAtCompileTime - 1) = det;
222 template <
typename Scalar,
int Dim>
251 const VectorType UnitZ = Ones - UnitX - UnitY;
255 BoxType
a(-Ones, Ones);
265 BoxType
c(minPoint, maxPoint);
268 IsometryTransform tf2 = IsometryTransform::Identity();
293 AffineTransform atf = AffineTransform::Identity();
294 atf.linearExt()(0, 1) =
Scalar(1);
295 c = BoxType(-Ones, Ones);
312 enum { Dim = BoxType::AmbientDimAtCompileTime };
318 const Index dim = box.dim();
326 BoxType
c(minPoint, maxPoint);
331 VectorType cornerBR = (
c.min)(); cornerBR[0] = cornerTR[0];
332 VectorType cornerTL = (
c.max)(); cornerTL[0] = cornerBL[0];
334 NonInteger angle = NonInteger(
EIGEN_PI/3);
336 IsometryTransform tf2;
343 cornerBL = tf2 * cornerBL;
344 cornerBR = tf2 * cornerBR;
345 cornerTL = tf2 * cornerTL;
346 cornerTR = tf2 * cornerTR;
350 minCorner[0] = (
min)((
min)(cornerBL[0], cornerBR[0]), (
min)(cornerTL[0], cornerTR[0]));
351 maxCorner[0] = (
max)((
max)(cornerBL[0], cornerBR[0]), (
max)(cornerTL[0], cornerTR[0]));
352 minCorner[1] = (
min)((
min)(cornerBL[1], cornerBR[1]), (
min)(cornerTL[1], cornerTR[1]));
353 maxCorner[1] = (
max)((
max)(cornerBL[1], cornerBR[1]), (
max)(cornerTL[1], cornerTR[1]));
366 maxCornerValue[1] =
Scalar(3 *
cos(angle));
371 for (
size_t i = 0;
i < 10; ++
i)
375 minCorner[
d] = internal::random<Scalar>(-10,10);
376 maxCorner[
d] = minCorner[
d] + internal::random<Scalar>(0, 10);
379 c = BoxType(minCorner, maxCorner);
383 typename AffineTransform::LinearMatrixType
rotation =
384 randomRotationMatrix<typename AffineTransform::LinearMatrixType>();
388 tf2.translate(VectorType::Random());
393 minCorner =
corners.rowwise().minCoeff();
394 maxCorner =
corners.rowwise().maxCoeff();
401 for (
size_t i = 0;
i < 10; ++
i)
405 minCorner[
d] = internal::random<Scalar>(-10,10);
406 maxCorner[
d] = minCorner[
d] + internal::random<Scalar>(0, 10);
409 c = BoxType(minCorner, maxCorner);
413 AffineTransform atf = AffineTransform::Identity();
414 atf.linearExt() = AffineTransform::LinearPart::Random();
415 atf.translate(VectorType::Random());
420 minCorner =
corners.rowwise().minCoeff();
421 maxCorner =
corners.rowwise().maxCoeff();
428 template<
typename BoxType>
435 const Index dim = box.dim();
445 const int Dim = BoxType::AmbientDimAtCompileTime;
456 Vector2f
m;
m << -1.0f, -2.0f;
457 Vector2f
M;
M << 1.0f, 5.0f;
459 typedef AlignedBox2f BoxType;
462 Vector2f sides =
M-
m;
474 Vector2f bottomRight; bottomRight <<
M[0],
m[1];
483 Vector3i
m;
m << -1, -2, 0;
484 Vector3i
M;
M << 1, 5, 3;
486 typedef AlignedBox3i BoxType;
489 Vector3i sides =
M-
m;
500 Vector3i bottomRightFloor; bottomRightFloor <<
M[0],
m[1],
m[2];
501 Vector3i topLeftFloor; topLeftFloor <<
m[0],
M[1],
m[2];
502 VERIFY_IS_APPROX( bottomRightFloor, box.corner( BoxType::BottomRightFloor ) );
524 CALL_SUBTEST_10( (alignedboxRotatable<AlignedBox2i, Matrix2i>(AlignedBox2i(), &rotate2DIntegral<int, Matrix2i>)) );
525 CALL_SUBTEST_11( (alignedboxRotatable<AlignedBox3i, Matrix3i>(AlignedBox3i(), &rotate3DZAxisIntegral<int, Matrix3i>)) );