geo_alignedbox.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. // This file is part of Eigen, a lightweight C++ template library
  2. // for linear algebra.
  3. //
  4. // Copyright (C) 2008-2009 Gael Guennebaud <gael.guennebaud@inria.fr>
  5. //
  6. // This Source Code Form is subject to the terms of the Mozilla
  7. // Public License v. 2.0. If a copy of the MPL was not distributed
  8. // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
  9. #include "main.h"
  10. #include <Eigen/Geometry>
  11. using namespace std;
  12. // NOTE the following workaround was needed on some 32 bits builds to kill extra precision of x87 registers.
  13. // It seems that it is not needed anymore, but let's keep it here, just in case...
  14. template<typename T> EIGEN_DONT_INLINE
  15. void kill_extra_precision(T& /* x */) {
  16. // This one worked but triggered a warning:
  17. /* eigen_assert((void*)(&x) != (void*)0); */
  18. // An alternative could be:
  19. /* volatile T tmp = x; */
  20. /* x = tmp; */
  21. }
  22. template<typename BoxType> void alignedbox(const BoxType& box)
  23. {
  24. /* this test covers the following files:
  25. AlignedBox.h
  26. */
  27. typedef typename BoxType::Scalar Scalar;
  28. typedef NumTraits<Scalar> ScalarTraits;
  29. typedef typename ScalarTraits::Real RealScalar;
  30. typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
  31. const Index dim = box.dim();
  32. VectorType p0 = VectorType::Random(dim);
  33. VectorType p1 = VectorType::Random(dim);
  34. while( p1 == p0 ){
  35. p1 = VectorType::Random(dim); }
  36. RealScalar s1 = internal::random<RealScalar>(0,1);
  37. BoxType b0(dim);
  38. BoxType b1(VectorType::Random(dim),VectorType::Random(dim));
  39. BoxType b2;
  40. kill_extra_precision(b1);
  41. kill_extra_precision(p0);
  42. kill_extra_precision(p1);
  43. b0.extend(p0);
  44. b0.extend(p1);
  45. VERIFY(b0.contains(p0*s1+(Scalar(1)-s1)*p1));
  46. VERIFY(b0.contains(b0.center()));
  47. VERIFY_IS_APPROX(b0.center(),(p0+p1)/Scalar(2));
  48. (b2 = b0).extend(b1);
  49. VERIFY(b2.contains(b0));
  50. VERIFY(b2.contains(b1));
  51. VERIFY_IS_APPROX(b2.clamp(b0), b0);
  52. // intersection
  53. BoxType box1(VectorType::Random(dim));
  54. box1.extend(VectorType::Random(dim));
  55. BoxType box2(VectorType::Random(dim));
  56. box2.extend(VectorType::Random(dim));
  57. VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty());
  58. // alignment -- make sure there is no memory alignment assertion
  59. BoxType *bp0 = new BoxType(dim);
  60. BoxType *bp1 = new BoxType(dim);
  61. bp0->extend(*bp1);
  62. delete bp0;
  63. delete bp1;
  64. // sampling
  65. for( int i=0; i<10; ++i )
  66. {
  67. VectorType r = b0.sample();
  68. VERIFY(b0.contains(r));
  69. }
  70. }
  71. template<typename BoxType> void alignedboxTranslatable(const BoxType& box)
  72. {
  73. typedef typename BoxType::Scalar Scalar;
  74. typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
  75. typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Isometry> IsometryTransform;
  76. typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Affine> AffineTransform;
  77. alignedbox(box);
  78. const VectorType Ones = VectorType::Ones();
  79. const VectorType UnitX = VectorType::UnitX();
  80. const Index dim = box.dim();
  81. // box((-1, -1, -1), (1, 1, 1))
  82. BoxType a(-Ones, Ones);
  83. VERIFY_IS_APPROX(a.sizes(), Ones * Scalar(2));
  84. BoxType b = a;
  85. VectorType translate = Ones;
  86. translate[0] = Scalar(2);
  87. b.translate(translate);
  88. // translate by (2, 1, 1) -> box((1, 0, 0), (3, 2, 2))
  89. VERIFY_IS_APPROX(b.sizes(), Ones * Scalar(2));
  90. VERIFY_IS_APPROX((b.min)(), UnitX);
  91. VERIFY_IS_APPROX((b.max)(), Ones * Scalar(2) + UnitX);
  92. // Test transform
  93. IsometryTransform tf = IsometryTransform::Identity();
  94. tf.translation() = -translate;
  95. BoxType c = b.transformed(tf);
  96. // translate by (-2, -1, -1) -> box((-1, -1, -1), (1, 1, 1))
  97. VERIFY_IS_APPROX(c.sizes(), a.sizes());
  98. VERIFY_IS_APPROX((c.min)(), (a.min)());
  99. VERIFY_IS_APPROX((c.max)(), (a.max)());
  100. c.transform(tf);
  101. // translate by (-2, -1, -1) -> box((-3, -2, -2), (-1, 0, 0))
  102. VERIFY_IS_APPROX(c.sizes(), a.sizes());
  103. VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) - UnitX);
  104. VERIFY_IS_APPROX((c.max)(), -UnitX);
  105. // Scaling
  106. AffineTransform atf = AffineTransform::Identity();
  107. atf.scale(Scalar(3));
  108. c.transform(atf);
  109. // scale by 3 -> box((-9, -6, -6), (-3, 0, 0))
  110. VERIFY_IS_APPROX(c.sizes(), Scalar(3) * a.sizes());
  111. VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-6) - UnitX * Scalar(3));
  112. VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(-3));
  113. atf = AffineTransform::Identity();
  114. atf.scale(Scalar(-3));
  115. c.transform(atf);
  116. // scale by -3 -> box((27, 18, 18), (9, 0, 0))
  117. VERIFY_IS_APPROX(c.sizes(), Scalar(9) * a.sizes());
  118. VERIFY_IS_APPROX((c.min)(), UnitX * Scalar(9));
  119. VERIFY_IS_APPROX((c.max)(), Ones * Scalar(18) + UnitX * Scalar(9));
  120. // Check identity transform within numerical precision.
  121. BoxType transformedC = c.transformed(IsometryTransform::Identity());
  122. VERIFY_IS_APPROX(transformedC, c);
  123. for (size_t i = 0; i < 10; ++i)
  124. {
  125. VectorType minCorner;
  126. VectorType maxCorner;
  127. for (Index d = 0; d < dim; ++d)
  128. {
  129. minCorner[d] = internal::random<Scalar>(-10,10);
  130. maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
  131. }
  132. c = BoxType(minCorner, maxCorner);
  133. translate = VectorType::Random();
  134. c.translate(translate);
  135. VERIFY_IS_APPROX((c.min)(), minCorner + translate);
  136. VERIFY_IS_APPROX((c.max)(), maxCorner + translate);
  137. }
  138. }
  139. template<typename Scalar, typename Rotation>
  140. Rotation rotate2D(Scalar angle) {
  141. return Rotation2D<Scalar>(angle);
  142. }
  143. template<typename Scalar, typename Rotation>
  144. Rotation rotate2DIntegral(typename NumTraits<Scalar>::NonInteger angle) {
  145. typedef typename NumTraits<Scalar>::NonInteger NonInteger;
  146. return Rotation2D<NonInteger>(angle).toRotationMatrix().
  147. template cast<Scalar>();
  148. }
  149. template<typename Scalar, typename Rotation>
  150. Rotation rotate3DZAxis(Scalar angle) {
  151. return AngleAxis<Scalar>(angle, Matrix<Scalar, 3, 1>(0, 0, 1));
  152. }
  153. template<typename Scalar, typename Rotation>
  154. Rotation rotate3DZAxisIntegral(typename NumTraits<Scalar>::NonInteger angle) {
  155. typedef typename NumTraits<Scalar>::NonInteger NonInteger;
  156. return AngleAxis<NonInteger>(angle, Matrix<NonInteger, 3, 1>(0, 0, 1)).
  157. toRotationMatrix().template cast<Scalar>();
  158. }
  159. template<typename Scalar, typename Rotation>
  160. Rotation rotate4DZWAxis(Scalar angle) {
  161. Rotation result = Matrix<Scalar, 4, 4>::Identity();
  162. result.block(0, 0, 3, 3) = rotate3DZAxis<Scalar, AngleAxisd>(angle).toRotationMatrix();
  163. return result;
  164. }
  165. template <typename MatrixType>
  166. MatrixType randomRotationMatrix()
  167. {
  168. // algorithm from
  169. // https://www.isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/III-7/103/2016/isprs-annals-III-7-103-2016.pdf
  170. const MatrixType rand = MatrixType::Random();
  171. const MatrixType q = rand.householderQr().householderQ();
  172. const JacobiSVD<MatrixType> svd = q.jacobiSvd(ComputeFullU | ComputeFullV);
  173. const typename MatrixType::Scalar det = (svd.matrixU() * svd.matrixV().transpose()).determinant();
  174. MatrixType diag = rand.Identity();
  175. diag(MatrixType::RowsAtCompileTime - 1, MatrixType::ColsAtCompileTime - 1) = det;
  176. const MatrixType rotation = svd.matrixU() * diag * svd.matrixV().transpose();
  177. return rotation;
  178. }
  179. template <typename Scalar, int Dim>
  180. Matrix<Scalar, Dim, (1<<Dim)> boxGetCorners(const Matrix<Scalar, Dim, 1>& min_, const Matrix<Scalar, Dim, 1>& max_)
  181. {
  182. Matrix<Scalar, Dim, (1<<Dim) > result;
  183. for(Index i=0; i<(1<<Dim); ++i)
  184. {
  185. for(Index j=0; j<Dim; ++j)
  186. result(j,i) = (i & (1<<j)) ? min_(j) : max_(j);
  187. }
  188. return result;
  189. }
  190. template<typename BoxType, typename Rotation> void alignedboxRotatable(
  191. const BoxType& box,
  192. Rotation (*rotate)(typename NumTraits<typename BoxType::Scalar>::NonInteger /*_angle*/))
  193. {
  194. alignedboxTranslatable(box);
  195. typedef typename BoxType::Scalar Scalar;
  196. typedef typename NumTraits<Scalar>::NonInteger NonInteger;
  197. typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
  198. typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Isometry> IsometryTransform;
  199. typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Affine> AffineTransform;
  200. const VectorType Zero = VectorType::Zero();
  201. const VectorType Ones = VectorType::Ones();
  202. const VectorType UnitX = VectorType::UnitX();
  203. const VectorType UnitY = VectorType::UnitY();
  204. // this is vector (0, 0, -1, -1, -1, ...), i.e. with zeros at first and second dimensions
  205. const VectorType UnitZ = Ones - UnitX - UnitY;
  206. // in this kind of comments the 3D case values will be illustrated
  207. // box((-1, -1, -1), (1, 1, 1))
  208. BoxType a(-Ones, Ones);
  209. // to allow templating this test for both 2D and 3D cases, we always set all
  210. // but the first coordinate to the same value; so basically 3D case works as
  211. // if you were looking at the scene from top
  212. VectorType minPoint = -2 * Ones;
  213. minPoint[0] = -3;
  214. VectorType maxPoint = Zero;
  215. maxPoint[0] = -1;
  216. BoxType c(minPoint, maxPoint);
  217. // box((-3, -2, -2), (-1, 0, 0))
  218. IsometryTransform tf2 = IsometryTransform::Identity();
  219. // for some weird reason the following statement has to be put separate from
  220. // the following rotate call, otherwise precision problems arise...
  221. Rotation rot = rotate(NonInteger(EIGEN_PI));
  222. tf2.rotate(rot);
  223. c.transform(tf2);
  224. // rotate by 180 deg around origin -> box((1, 0, -2), (3, 2, 0))
  225. VERIFY_IS_APPROX(c.sizes(), a.sizes());
  226. VERIFY_IS_APPROX((c.min)(), UnitX - UnitZ * Scalar(2));
  227. VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(3) + UnitY * Scalar(2));
  228. rot = rotate(NonInteger(EIGEN_PI / 2));
  229. tf2.setIdentity();
  230. tf2.rotate(rot);
  231. c.transform(tf2);
  232. // rotate by 90 deg around origin -> box((-2, 1, -2), (0, 3, 0))
  233. VERIFY_IS_APPROX(c.sizes(), a.sizes());
  234. VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) + UnitY * Scalar(3));
  235. VERIFY_IS_APPROX((c.max)(), UnitY * Scalar(3));
  236. // box((-1, -1, -1), (1, 1, 1))
  237. AffineTransform atf = AffineTransform::Identity();
  238. atf.linearExt()(0, 1) = Scalar(1);
  239. c = BoxType(-Ones, Ones);
  240. c.transform(atf);
  241. // 45 deg shear in x direction -> box((-2, -1, -1), (2, 1, 1))
  242. VERIFY_IS_APPROX(c.sizes(), Ones * Scalar(2) + UnitX * Scalar(2));
  243. VERIFY_IS_APPROX((c.min)(), -Ones - UnitX);
  244. VERIFY_IS_APPROX((c.max)(), Ones + UnitX);
  245. }
  246. template<typename BoxType, typename Rotation> void alignedboxNonIntegralRotatable(
  247. const BoxType& box,
  248. Rotation (*rotate)(typename NumTraits<typename BoxType::Scalar>::NonInteger /*_angle*/))
  249. {
  250. alignedboxRotatable(box, rotate);
  251. typedef typename BoxType::Scalar Scalar;
  252. typedef typename NumTraits<Scalar>::NonInteger NonInteger;
  253. enum { Dim = BoxType::AmbientDimAtCompileTime };
  254. typedef Matrix<Scalar, Dim, 1> VectorType;
  255. typedef Matrix<Scalar, Dim, (1 << Dim)> CornersType;
  256. typedef Transform<Scalar, Dim, Isometry> IsometryTransform;
  257. typedef Transform<Scalar, Dim, Affine> AffineTransform;
  258. const Index dim = box.dim();
  259. const VectorType Zero = VectorType::Zero();
  260. const VectorType Ones = VectorType::Ones();
  261. VectorType minPoint = -2 * Ones;
  262. minPoint[1] = 1;
  263. VectorType maxPoint = Zero;
  264. maxPoint[1] = 3;
  265. BoxType c(minPoint, maxPoint);
  266. // ((-2, 1, -2), (0, 3, 0))
  267. VectorType cornerBL = (c.min)();
  268. VectorType cornerTR = (c.max)();
  269. VectorType cornerBR = (c.min)(); cornerBR[0] = cornerTR[0];
  270. VectorType cornerTL = (c.max)(); cornerTL[0] = cornerBL[0];
  271. NonInteger angle = NonInteger(EIGEN_PI/3);
  272. Rotation rot = rotate(angle);
  273. IsometryTransform tf2;
  274. tf2.setIdentity();
  275. tf2.rotate(rot);
  276. c.transform(tf2);
  277. // rotate by 60 deg -> box((-3.59, -1.23, -2), (-0.86, 1.5, 0))
  278. cornerBL = tf2 * cornerBL;
  279. cornerBR = tf2 * cornerBR;
  280. cornerTL = tf2 * cornerTL;
  281. cornerTR = tf2 * cornerTR;
  282. VectorType minCorner = Ones * Scalar(-2);
  283. VectorType maxCorner = Zero;
  284. minCorner[0] = (min)((min)(cornerBL[0], cornerBR[0]), (min)(cornerTL[0], cornerTR[0]));
  285. maxCorner[0] = (max)((max)(cornerBL[0], cornerBR[0]), (max)(cornerTL[0], cornerTR[0]));
  286. minCorner[1] = (min)((min)(cornerBL[1], cornerBR[1]), (min)(cornerTL[1], cornerTR[1]));
  287. maxCorner[1] = (max)((max)(cornerBL[1], cornerBR[1]), (max)(cornerTL[1], cornerTR[1]));
  288. for (Index d = 2; d < dim; ++d)
  289. VERIFY_IS_APPROX(c.sizes()[d], Scalar(2));
  290. VERIFY_IS_APPROX((c.min)(), minCorner);
  291. VERIFY_IS_APPROX((c.max)(), maxCorner);
  292. VectorType minCornerValue = Ones * Scalar(-2);
  293. VectorType maxCornerValue = Zero;
  294. minCornerValue[0] = Scalar(Scalar(-sqrt(2*2 + 3*3)) * Scalar(cos(Scalar(atan(2.0/3.0)) - angle/2)));
  295. minCornerValue[1] = Scalar(Scalar(-sqrt(1*1 + 2*2)) * Scalar(sin(Scalar(atan(2.0/1.0)) - angle/2)));
  296. maxCornerValue[0] = Scalar(-sin(angle));
  297. maxCornerValue[1] = Scalar(3 * cos(angle));
  298. VERIFY_IS_APPROX((c.min)(), minCornerValue);
  299. VERIFY_IS_APPROX((c.max)(), maxCornerValue);
  300. // randomized test - translate and rotate the box and compare to a box made of transformed vertices
  301. for (size_t i = 0; i < 10; ++i)
  302. {
  303. for (Index d = 0; d < dim; ++d)
  304. {
  305. minCorner[d] = internal::random<Scalar>(-10,10);
  306. maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
  307. }
  308. c = BoxType(minCorner, maxCorner);
  309. CornersType corners = boxGetCorners(minCorner, maxCorner);
  310. typename AffineTransform::LinearMatrixType rotation =
  311. randomRotationMatrix<typename AffineTransform::LinearMatrixType>();
  312. tf2.setIdentity();
  313. tf2.rotate(rotation);
  314. tf2.translate(VectorType::Random());
  315. c.transform(tf2);
  316. corners = tf2 * corners;
  317. minCorner = corners.rowwise().minCoeff();
  318. maxCorner = corners.rowwise().maxCoeff();
  319. VERIFY_IS_APPROX((c.min)(), minCorner);
  320. VERIFY_IS_APPROX((c.max)(), maxCorner);
  321. }
  322. // randomized test - transform the box with a random affine matrix and compare to a box made of transformed vertices
  323. for (size_t i = 0; i < 10; ++i)
  324. {
  325. for (Index d = 0; d < dim; ++d)
  326. {
  327. minCorner[d] = internal::random<Scalar>(-10,10);
  328. maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
  329. }
  330. c = BoxType(minCorner, maxCorner);
  331. CornersType corners = boxGetCorners(minCorner, maxCorner);
  332. AffineTransform atf = AffineTransform::Identity();
  333. atf.linearExt() = AffineTransform::LinearPart::Random();
  334. atf.translate(VectorType::Random());
  335. c.transform(atf);
  336. corners = atf * corners;
  337. minCorner = corners.rowwise().minCoeff();
  338. maxCorner = corners.rowwise().maxCoeff();
  339. VERIFY_IS_APPROX((c.min)(), minCorner);
  340. VERIFY_IS_APPROX((c.max)(), maxCorner);
  341. }
  342. }
  343. template<typename BoxType>
  344. void alignedboxCastTests(const BoxType& box)
  345. {
  346. // casting
  347. typedef typename BoxType::Scalar Scalar;
  348. typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
  349. const Index dim = box.dim();
  350. VectorType p0 = VectorType::Random(dim);
  351. VectorType p1 = VectorType::Random(dim);
  352. BoxType b0(dim);
  353. b0.extend(p0);
  354. b0.extend(p1);
  355. const int Dim = BoxType::AmbientDimAtCompileTime;
  356. typedef typename GetDifferentType<Scalar>::type OtherScalar;
  357. AlignedBox<OtherScalar,Dim> hp1f = b0.template cast<OtherScalar>();
  358. VERIFY_IS_APPROX(hp1f.template cast<Scalar>(),b0);
  359. AlignedBox<Scalar,Dim> hp1d = b0.template cast<Scalar>();
  360. VERIFY_IS_APPROX(hp1d.template cast<Scalar>(),b0);
  361. }
  362. void specificTest1()
  363. {
  364. Vector2f m; m << -1.0f, -2.0f;
  365. Vector2f M; M << 1.0f, 5.0f;
  366. typedef AlignedBox2f BoxType;
  367. BoxType box( m, M );
  368. Vector2f sides = M-m;
  369. VERIFY_IS_APPROX(sides, box.sizes() );
  370. VERIFY_IS_APPROX(sides[1], box.sizes()[1] );
  371. VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff() );
  372. VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff() );
  373. VERIFY_IS_APPROX( 14.0f, box.volume() );
  374. VERIFY_IS_APPROX( 53.0f, box.diagonal().squaredNorm() );
  375. VERIFY_IS_APPROX( std::sqrt( 53.0f ), box.diagonal().norm() );
  376. VERIFY_IS_APPROX( m, box.corner( BoxType::BottomLeft ) );
  377. VERIFY_IS_APPROX( M, box.corner( BoxType::TopRight ) );
  378. Vector2f bottomRight; bottomRight << M[0], m[1];
  379. Vector2f topLeft; topLeft << m[0], M[1];
  380. VERIFY_IS_APPROX( bottomRight, box.corner( BoxType::BottomRight ) );
  381. VERIFY_IS_APPROX( topLeft, box.corner( BoxType::TopLeft ) );
  382. }
  383. void specificTest2()
  384. {
  385. Vector3i m; m << -1, -2, 0;
  386. Vector3i M; M << 1, 5, 3;
  387. typedef AlignedBox3i BoxType;
  388. BoxType box( m, M );
  389. Vector3i sides = M-m;
  390. VERIFY_IS_APPROX(sides, box.sizes() );
  391. VERIFY_IS_APPROX(sides[1], box.sizes()[1] );
  392. VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff() );
  393. VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff() );
  394. VERIFY_IS_APPROX( 42, box.volume() );
  395. VERIFY_IS_APPROX( 62, box.diagonal().squaredNorm() );
  396. VERIFY_IS_APPROX( m, box.corner( BoxType::BottomLeftFloor ) );
  397. VERIFY_IS_APPROX( M, box.corner( BoxType::TopRightCeil ) );
  398. Vector3i bottomRightFloor; bottomRightFloor << M[0], m[1], m[2];
  399. Vector3i topLeftFloor; topLeftFloor << m[0], M[1], m[2];
  400. VERIFY_IS_APPROX( bottomRightFloor, box.corner( BoxType::BottomRightFloor ) );
  401. VERIFY_IS_APPROX( topLeftFloor, box.corner( BoxType::TopLeftFloor ) );
  402. }
  403. EIGEN_DECLARE_TEST(geo_alignedbox)
  404. {
  405. for(int i = 0; i < g_repeat; i++)
  406. {
  407. CALL_SUBTEST_1( (alignedboxNonIntegralRotatable<AlignedBox2f, Rotation2Df>(AlignedBox2f(), &rotate2D)) );
  408. CALL_SUBTEST_2( alignedboxCastTests(AlignedBox2f()) );
  409. CALL_SUBTEST_3( (alignedboxNonIntegralRotatable<AlignedBox3f, AngleAxisf>(AlignedBox3f(), &rotate3DZAxis)) );
  410. CALL_SUBTEST_4( alignedboxCastTests(AlignedBox3f()) );
  411. CALL_SUBTEST_5( (alignedboxNonIntegralRotatable<AlignedBox4d, Matrix4d>(AlignedBox4d(), &rotate4DZWAxis)) );
  412. CALL_SUBTEST_6( alignedboxCastTests(AlignedBox4d()) );
  413. CALL_SUBTEST_7( alignedboxTranslatable(AlignedBox1d()) );
  414. CALL_SUBTEST_8( alignedboxCastTests(AlignedBox1d()) );
  415. CALL_SUBTEST_9( alignedboxTranslatable(AlignedBox1i()) );
  416. CALL_SUBTEST_10( (alignedboxRotatable<AlignedBox2i, Matrix2i>(AlignedBox2i(), &rotate2DIntegral<int, Matrix2i>)) );
  417. CALL_SUBTEST_11( (alignedboxRotatable<AlignedBox3i, Matrix3i>(AlignedBox3i(), &rotate3DZAxisIntegral<int, Matrix3i>)) );
  418. CALL_SUBTEST_14( alignedbox(AlignedBox<double,Dynamic>(4)) );
  419. }
  420. CALL_SUBTEST_12( specificTest1() );
  421. CALL_SUBTEST_13( specificTest2() );
  422. }