geo_alignedbox.cpp File Reference
#include "main.h"
#include <Eigen/Geometry>

Functions

template<typename T >
EIGEN_DONT_INLINE void kill_extra_precision (T &)
 
template<typename BoxType >
void alignedbox (const BoxType &box)
 
template<typename BoxType >
void alignedboxTranslatable (const BoxType &box)
 
template<typename Scalar , typename Rotation >
Rotation rotate2D (Scalar angle)
 
template<typename Scalar , typename Rotation >
Rotation rotate2DIntegral (typename NumTraits< Scalar >::NonInteger angle)
 
template<typename Scalar , typename Rotation >
Rotation rotate3DZAxis (Scalar angle)
 
template<typename Scalar , typename Rotation >
Rotation rotate3DZAxisIntegral (typename NumTraits< Scalar >::NonInteger angle)
 
template<typename Scalar , typename Rotation >
Rotation rotate4DZWAxis (Scalar angle)
 
template<typename MatrixType >
MatrixType randomRotationMatrix ()
 
template<typename Scalar , int Dim>
Matrix< Scalar, Dim,(1<< Dim)> boxGetCorners (const Matrix< Scalar, Dim, 1 > &min_, const Matrix< Scalar, Dim, 1 > &max_)
 
template<typename BoxType , typename Rotation >
void alignedboxRotatable (const BoxType &box, Rotation(*rotate)(typename NumTraits< typename BoxType::Scalar >::NonInteger))
 
template<typename BoxType , typename Rotation >
void alignedboxNonIntegralRotatable (const BoxType &box, Rotation(*rotate)(typename NumTraits< typename BoxType::Scalar >::NonInteger))
 
template<typename BoxType >
void alignedboxCastTests (const BoxType &box)
 
void specificTest1 ()
 
void specificTest2 ()
 
 EIGEN_DECLARE_TEST (geo_alignedbox)
 

Function Documentation

◆ alignedbox()

template<typename BoxType >
void alignedbox ( const BoxType &  box)
28  {
29  /* this test covers the following files:
30  AlignedBox.h
31  */
32  typedef typename BoxType::Scalar Scalar;
33  typedef NumTraits<Scalar> ScalarTraits;
34  typedef typename ScalarTraits::Real RealScalar;
36 
37  const Index dim = box.dim();
38 
39  VectorType p0 = VectorType::Random(dim) / Scalar(2);
40  VectorType p1 = VectorType::Random(dim) / Scalar(2);
41  while (p1 == p0) {
42  p1 = VectorType::Random(dim) / Scalar(2);
43  }
44  RealScalar s1 = internal::random<RealScalar>(0, 1);
45 
46  BoxType b0(dim);
47  BoxType b1(VectorType::Random(dim), VectorType::Random(dim));
48  BoxType b2;
49 
53 
54  VERIFY(numext::equal_strict(b0.volume(), Scalar(0)));
55 
56  b0.extend(p0);
57  b0.extend(p1);
58  VERIFY(b0.contains(p0 * s1 + (Scalar(1) - s1) * p1));
59  VERIFY(b0.contains(b0.center()));
60  VERIFY_IS_APPROX(b0.center(), (p0 + p1) / Scalar(2));
61 
62  (b2 = b0).extend(b1);
63  VERIFY(b2.contains(b0));
64  VERIFY(b2.contains(b1));
65  VERIFY_IS_APPROX(b2.clamp(b0), b0);
66 
67  // intersection
68  BoxType box1(VectorType::Random(dim));
69  box1.extend(VectorType::Random(dim));
70  BoxType box2(VectorType::Random(dim));
71  box2.extend(VectorType::Random(dim));
72 
73  VERIFY(box1.intersects(box2) == !box1.intersection(box2).isEmpty());
74 
75  // alignment -- make sure there is no memory alignment assertion
76  BoxType* bp0 = new BoxType(dim);
77  BoxType* bp1 = new BoxType(dim);
78  bp0->extend(*bp1);
79  delete bp0;
80  delete bp1;
81 
82  // sampling
83  for (int i = 0; i < 10; ++i) {
84  VectorType r = b0.sample();
85  VERIFY(b0.contains(r));
86  }
87 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Vector3f p0
Definition: MatrixBase_all.cpp:2
Vector3f p1
Definition: MatrixBase_all.cpp:2
SCALAR Scalar
Definition: bench_gemm.cpp:45
NumTraits< Scalar >::Real RealScalar
Definition: bench_gemm.cpp:46
boost::multiprecision::number< boost::multiprecision::cpp_dec_float< 100 >, boost::multiprecision::et_on > Real
Definition: boostmultiprec.cpp:77
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186
EIGEN_DONT_INLINE void kill_extra_precision(T &)
Definition: geo_alignedbox.cpp:19
#define VERIFY_IS_APPROX(a, b)
Definition: integer_types.cpp:13
#define VERIFY(a)
Definition: main.h:362
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bool equal_strict(const X &x, const Y &y)
Definition: Meta.h:571
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:83
r
Definition: UniformPSDSelfTest.py:20
Definition: fft_test_shared.h:66

References Eigen::numext::equal_strict(), i, kill_extra_precision(), p0, p1, UniformPSDSelfTest::r, VERIFY, and VERIFY_IS_APPROX.

Referenced by alignedboxTranslatable(), and EIGEN_DECLARE_TEST().

◆ alignedboxCastTests()

template<typename BoxType >
void alignedboxCastTests ( const BoxType &  box)
416  {
417  // casting
418  typedef typename BoxType::Scalar Scalar;
420 
421  const Index dim = box.dim();
422 
423  VectorType p0 = VectorType::Random(dim);
424  VectorType p1 = VectorType::Random(dim);
425 
426  BoxType b0(dim);
427 
428  VERIFY(numext::equal_strict(b0.volume(), Scalar(0)));
429 
430  b0.extend(p0);
431  b0.extend(p1);
432 
433  const int Dim = BoxType::AmbientDimAtCompileTime;
434  typedef typename GetDifferentType<Scalar>::type OtherScalar;
435  AlignedBox<OtherScalar, Dim> hp1f = b0.template cast<OtherScalar>();
436  VERIFY_IS_APPROX(hp1f.template cast<Scalar>(), b0);
437  AlignedBox<Scalar, Dim> hp1d = b0.template cast<Scalar>();
438  VERIFY_IS_APPROX(hp1d.template cast<Scalar>(), b0);
439 }
An axis aligned box.
Definition: AlignedBox.h:69
static const unsigned Dim
Problem dimension.
Definition: two_d_tilted_square.cc:62
Definition: main.h:736

References Global_Variables::Dim, Eigen::numext::equal_strict(), p0, p1, VERIFY, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().

◆ alignedboxNonIntegralRotatable()

template<typename BoxType , typename Rotation >
void alignedboxNonIntegralRotatable ( const BoxType &  box,
Rotation(*)(typename NumTraits< typename BoxType::Scalar >::NonInteger)  rotate 
)
297  {
298  alignedboxRotatable(box, rotate);
299 
300  typedef typename BoxType::Scalar Scalar;
301  typedef typename NumTraits<Scalar>::NonInteger NonInteger;
302  enum { Dim = BoxType::AmbientDimAtCompileTime };
304  typedef Matrix<Scalar, Dim, (1 << Dim)> CornersType;
305  typedef Transform<Scalar, Dim, Isometry> IsometryTransform;
306  typedef Transform<Scalar, Dim, Affine> AffineTransform;
307 
308  const Index dim = box.dim();
309  const VectorType Zero = VectorType::Zero();
310  const VectorType Ones = VectorType::Ones();
311 
312  VectorType minPoint = -2 * Ones;
313  minPoint[1] = 1;
314  VectorType maxPoint = Zero;
315  maxPoint[1] = 3;
316  BoxType c(minPoint, maxPoint);
317  // ((-2, 1, -2), (0, 3, 0))
318 
319  VectorType cornerBL = (c.min)();
320  VectorType cornerTR = (c.max)();
321  VectorType cornerBR = (c.min)();
322  cornerBR[0] = cornerTR[0];
323  VectorType cornerTL = (c.max)();
324  cornerTL[0] = cornerBL[0];
325 
326  NonInteger angle = NonInteger(EIGEN_PI / 3);
327  Rotation rot = rotate(angle);
328  IsometryTransform tf2;
329  tf2.setIdentity();
330  tf2.rotate(rot);
331 
332  c.transform(tf2);
333  // rotate by 60 deg -> box((-3.59, -1.23, -2), (-0.86, 1.5, 0))
334 
335  cornerBL = tf2 * cornerBL;
336  cornerBR = tf2 * cornerBR;
337  cornerTL = tf2 * cornerTL;
338  cornerTR = tf2 * cornerTR;
339 
340  VectorType minCorner = Ones * Scalar(-2);
341  VectorType maxCorner = Zero;
342  minCorner[0] = (min)((min)(cornerBL[0], cornerBR[0]), (min)(cornerTL[0], cornerTR[0]));
343  maxCorner[0] = (max)((max)(cornerBL[0], cornerBR[0]), (max)(cornerTL[0], cornerTR[0]));
344  minCorner[1] = (min)((min)(cornerBL[1], cornerBR[1]), (min)(cornerTL[1], cornerTR[1]));
345  maxCorner[1] = (max)((max)(cornerBL[1], cornerBR[1]), (max)(cornerTL[1], cornerTR[1]));
346 
347  for (Index d = 2; d < dim; ++d) VERIFY_IS_APPROX(c.sizes()[d], Scalar(2));
348 
349  VERIFY_IS_APPROX((c.min)(), minCorner);
350  VERIFY_IS_APPROX((c.max)(), maxCorner);
351 
352  VectorType minCornerValue = Ones * Scalar(-2);
353  VectorType maxCornerValue = Zero;
354  minCornerValue[0] = Scalar(Scalar(-sqrt(2 * 2 + 3 * 3)) * Scalar(cos(Scalar(atan(2.0 / 3.0)) - angle / 2)));
355  minCornerValue[1] = Scalar(Scalar(-sqrt(1 * 1 + 2 * 2)) * Scalar(sin(Scalar(atan(2.0 / 1.0)) - angle / 2)));
356  maxCornerValue[0] = Scalar(-sin(angle));
357  maxCornerValue[1] = Scalar(3 * cos(angle));
358  VERIFY_IS_APPROX((c.min)(), minCornerValue);
359  VERIFY_IS_APPROX((c.max)(), maxCornerValue);
360 
361  // randomized test - translate and rotate the box and compare to a box made of transformed vertices
362  for (size_t i = 0; i < 10; ++i) {
363  for (Index d = 0; d < dim; ++d) {
364  minCorner[d] = internal::random<Scalar>(-10, 10);
365  maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
366  }
367 
368  c = BoxType(minCorner, maxCorner);
369 
370  CornersType corners = boxGetCorners(minCorner, maxCorner);
371 
372  typename AffineTransform::LinearMatrixType rotation =
373  randomRotationMatrix<typename AffineTransform::LinearMatrixType>();
374 
375  tf2.setIdentity();
376  tf2.rotate(rotation);
377  tf2.translate(VectorType::Random());
378 
379  c.transform(tf2);
380  corners = tf2 * corners;
381 
382  minCorner = corners.rowwise().minCoeff();
383  maxCorner = corners.rowwise().maxCoeff();
384 
385  VERIFY_IS_APPROX((c.min)(), minCorner);
386  VERIFY_IS_APPROX((c.max)(), maxCorner);
387  }
388 
389  // randomized test - transform the box with a random affine matrix and compare to a box made of transformed vertices
390  for (size_t i = 0; i < 10; ++i) {
391  for (Index d = 0; d < dim; ++d) {
392  minCorner[d] = internal::random<Scalar>(-10, 10);
393  maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
394  }
395 
396  c = BoxType(minCorner, maxCorner);
397 
398  CornersType corners = boxGetCorners(minCorner, maxCorner);
399 
400  AffineTransform atf = AffineTransform::Identity();
401  atf.linearExt() = AffineTransform::LinearPart::Random();
402  atf.translate(VectorType::Random());
403 
404  c.transform(atf);
405  corners = atf * corners;
406 
407  minCorner = corners.rowwise().minCoeff();
408  maxCorner = corners.rowwise().maxCoeff();
409 
410  VERIFY_IS_APPROX((c.min)(), minCorner);
411  VERIFY_IS_APPROX((c.max)(), maxCorner);
412  }
413 }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
#define EIGEN_PI
Definition: MathFunctions.h:16
Represents an homogeneous transformation in a N dimensional space.
Definition: Transform.h:192
void corners(const MatrixType &m)
Definition: corners.cpp:17
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
Matrix< Scalar, Dim,(1<< Dim)> boxGetCorners(const Matrix< Scalar, Dim, 1 > &min_, const Matrix< Scalar, Dim, 1 > &max_)
Definition: geo_alignedbox.cpp:218
void alignedboxRotatable(const BoxType &box, Rotation(*rotate)(typename NumTraits< typename BoxType::Scalar >::NonInteger))
Definition: geo_alignedbox.cpp:227
EIGEN_BLAS_FUNC() rot(int *n, Scalar *px, int *incx, Scalar *py, int *incy, Scalar *pc, Scalar *ps)
Definition: level1_real_impl.h:88
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 atan(const bfloat16 &a)
Definition: BFloat16.h:636
double angle(const double &t)
Angular position as a function of time t.
Definition: jeffery_orbit.cc:98
int c
Definition: calibrate.py:100
double Zero
Definition: pseudosolid_node_update_elements.cc:35

References alignedboxRotatable(), Jeffery_Solution::angle(), Eigen::bfloat16_impl::atan(), boxGetCorners(), calibrate::c, corners(), cos(), Global_Variables::Dim, EIGEN_PI, i, max, min, rot(), sin(), sqrt(), VERIFY_IS_APPROX, and oomph::PseudoSolidHelper::Zero.

◆ alignedboxRotatable()

template<typename BoxType , typename Rotation >
void alignedboxRotatable ( const BoxType &  box,
Rotation(*)(typename NumTraits< typename BoxType::Scalar >::NonInteger)  rotate 
)
228  {
230 
231  typedef typename BoxType::Scalar Scalar;
232  typedef typename NumTraits<Scalar>::NonInteger NonInteger;
236 
237  const VectorType Zero = VectorType::Zero();
238  const VectorType Ones = VectorType::Ones();
239  const VectorType UnitX = VectorType::UnitX();
240  const VectorType UnitY = VectorType::UnitY();
241  // this is vector (0, 0, -1, -1, -1, ...), i.e. with zeros at first and second dimensions
242  const VectorType UnitZ = Ones - UnitX - UnitY;
243 
244  // in this kind of comments the 3D case values will be illustrated
245  // box((-1, -1, -1), (1, 1, 1))
246  BoxType a(-Ones, Ones);
247 
248  // to allow templating this test for both 2D and 3D cases, we always set all
249  // but the first coordinate to the same value; so basically 3D case works as
250  // if you were looking at the scene from top
251 
252  VectorType minPoint = -2 * Ones;
253  minPoint[0] = -3;
254  VectorType maxPoint = Zero;
255  maxPoint[0] = -1;
256  BoxType c(minPoint, maxPoint);
257  // box((-3, -2, -2), (-1, 0, 0))
258 
259  IsometryTransform tf2 = IsometryTransform::Identity();
260  // for some weird reason the following statement has to be put separate from
261  // the following rotate call, otherwise precision problems arise...
262  Rotation rot = rotate(NonInteger(EIGEN_PI));
263  tf2.rotate(rot);
264 
265  c.transform(tf2);
266  // rotate by 180 deg around origin -> box((1, 0, -2), (3, 2, 0))
267 
268  VERIFY_IS_APPROX(c.sizes(), a.sizes());
269  VERIFY_IS_APPROX((c.min)(), UnitX - UnitZ * Scalar(2));
270  VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(3) + UnitY * Scalar(2));
271 
272  rot = rotate(NonInteger(EIGEN_PI / 2));
273  tf2.setIdentity();
274  tf2.rotate(rot);
275 
276  c.transform(tf2);
277  // rotate by 90 deg around origin -> box((-2, 1, -2), (0, 3, 0))
278 
279  VERIFY_IS_APPROX(c.sizes(), a.sizes());
280  VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) + UnitY * Scalar(3));
281  VERIFY_IS_APPROX((c.max)(), UnitY * Scalar(3));
282 
283  // box((-1, -1, -1), (1, 1, 1))
284  AffineTransform atf = AffineTransform::Identity();
285  atf.linearExt()(0, 1) = Scalar(1);
286  c = BoxType(-Ones, Ones);
287  c.transform(atf);
288  // 45 deg shear in x direction -> box((-2, -1, -1), (2, 1, 1))
289 
290  VERIFY_IS_APPROX(c.sizes(), Ones * Scalar(2) + UnitX * Scalar(2));
291  VERIFY_IS_APPROX((c.min)(), -Ones - UnitX);
292  VERIFY_IS_APPROX((c.max)(), Ones + UnitX);
293 }
void alignedboxTranslatable(const BoxType &box)
Definition: geo_alignedbox.cpp:90
const Scalar * a
Definition: level2_cplx_impl.h:32

References a, alignedboxTranslatable(), calibrate::c, EIGEN_PI, rot(), VERIFY_IS_APPROX, and oomph::PseudoSolidHelper::Zero.

Referenced by alignedboxNonIntegralRotatable().

◆ alignedboxTranslatable()

template<typename BoxType >
void alignedboxTranslatable ( const BoxType &  box)
90  {
91  typedef typename BoxType::Scalar Scalar;
95 
96  alignedbox(box);
97 
98  const VectorType Ones = VectorType::Ones();
99  const VectorType UnitX = VectorType::UnitX();
100  const Index dim = box.dim();
101 
102  // box((-1, -1, -1), (1, 1, 1))
103  BoxType a(-Ones, Ones);
104 
105  VERIFY_IS_APPROX(a.sizes(), Ones * Scalar(2));
106 
107  BoxType b = a;
108  VectorType translate = Ones;
109  translate[0] = Scalar(2);
110  b.translate(translate);
111  // translate by (2, 1, 1) -> box((1, 0, 0), (3, 2, 2))
112 
113  VERIFY_IS_APPROX(b.sizes(), Ones * Scalar(2));
114  VERIFY_IS_APPROX((b.min)(), UnitX);
115  VERIFY_IS_APPROX((b.max)(), Ones * Scalar(2) + UnitX);
116 
117  // Test transform
118 
119  IsometryTransform tf = IsometryTransform::Identity();
120  tf.translation() = -translate;
121 
122  BoxType c = b.transformed(tf);
123  // translate by (-2, -1, -1) -> box((-1, -1, -1), (1, 1, 1))
124  VERIFY_IS_APPROX(c.sizes(), a.sizes());
125  VERIFY_IS_APPROX((c.min)(), (a.min)());
126  VERIFY_IS_APPROX((c.max)(), (a.max)());
127 
128  c.transform(tf);
129  // translate by (-2, -1, -1) -> box((-3, -2, -2), (-1, 0, 0))
130  VERIFY_IS_APPROX(c.sizes(), a.sizes());
131  VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-2) - UnitX);
132  VERIFY_IS_APPROX((c.max)(), -UnitX);
133 
134  // Scaling
135 
136  AffineTransform atf = AffineTransform::Identity();
137  atf.scale(Scalar(3));
138  c.transform(atf);
139  // scale by 3 -> box((-9, -6, -6), (-3, 0, 0))
140  VERIFY_IS_APPROX(c.sizes(), Scalar(3) * a.sizes());
141  VERIFY_IS_APPROX((c.min)(), Ones * Scalar(-6) - UnitX * Scalar(3));
142  VERIFY_IS_APPROX((c.max)(), UnitX * Scalar(-3));
143 
144  atf = AffineTransform::Identity();
145  atf.scale(Scalar(-3));
146  c.transform(atf);
147  // scale by -3 -> box((27, 18, 18), (9, 0, 0))
148  VERIFY_IS_APPROX(c.sizes(), Scalar(9) * a.sizes());
149  VERIFY_IS_APPROX((c.min)(), UnitX * Scalar(9));
150  VERIFY_IS_APPROX((c.max)(), Ones * Scalar(18) + UnitX * Scalar(9));
151 
152  // Check identity transform within numerical precision.
153  BoxType transformedC = c.transformed(IsometryTransform::Identity());
154  VERIFY_IS_APPROX(transformedC, c);
155 
156  for (size_t i = 0; i < 10; ++i) {
157  VectorType minCorner;
158  VectorType maxCorner;
159  for (Index d = 0; d < dim; ++d) {
160  minCorner[d] = internal::random<Scalar>(-10, 10);
161  maxCorner[d] = minCorner[d] + internal::random<Scalar>(0, 10);
162  }
163 
164  c = BoxType(minCorner, maxCorner);
165 
166  translate = VectorType::Random();
167  c.translate(translate);
168 
169  VERIFY_IS_APPROX((c.min)(), minCorner + translate);
170  VERIFY_IS_APPROX((c.max)(), maxCorner + translate);
171  }
172 }
Scalar * b
Definition: benchVecAdd.cpp:17
void alignedbox(const BoxType &box)
Definition: geo_alignedbox.cpp:28

References a, alignedbox(), b, calibrate::c, i, and VERIFY_IS_APPROX.

Referenced by alignedboxRotatable(), and EIGEN_DECLARE_TEST().

◆ boxGetCorners()

template<typename Scalar , int Dim>
Matrix<Scalar, Dim, (1 << Dim)> boxGetCorners ( const Matrix< Scalar, Dim, 1 > &  min_,
const Matrix< Scalar, Dim, 1 > &  max_ 
)
218  {
219  Matrix<Scalar, Dim, (1 << Dim)> result;
220  for (Index i = 0; i < (1 << Dim); ++i) {
221  for (Index j = 0; j < Dim; ++j) result(j, i) = (i & (Index(1) << j)) ? min_(j) : max_(j);
222  }
223  return result;
224 }
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References Global_Variables::Dim, i, and j.

Referenced by alignedboxNonIntegralRotatable().

◆ EIGEN_DECLARE_TEST()

EIGEN_DECLARE_TEST ( geo_alignedbox  )
498  {
499  for (int i = 0; i < g_repeat; i++) {
500  CALL_SUBTEST_1((alignedboxNonIntegralRotatable<AlignedBox2f, Rotation2Df>(AlignedBox2f(), &rotate2D)));
501  CALL_SUBTEST_2(alignedboxCastTests(AlignedBox2f()));
502 
503  CALL_SUBTEST_3((alignedboxNonIntegralRotatable<AlignedBox3f, AngleAxisf>(AlignedBox3f(), &rotate3DZAxis)));
504  CALL_SUBTEST_4(alignedboxCastTests(AlignedBox3f()));
505 
506  CALL_SUBTEST_5((alignedboxNonIntegralRotatable<AlignedBox4d, Matrix4d>(AlignedBox4d(), &rotate4DZWAxis)));
507  CALL_SUBTEST_6(alignedboxCastTests(AlignedBox4d()));
508 
509  CALL_SUBTEST_7(alignedboxTranslatable(AlignedBox1d()));
510  CALL_SUBTEST_8(alignedboxCastTests(AlignedBox1d()));
511 
512  CALL_SUBTEST_9(alignedboxTranslatable(AlignedBox1i()));
513  CALL_SUBTEST_10((alignedboxRotatable<AlignedBox2i, Matrix2i>(AlignedBox2i(), &rotate2DIntegral<int, Matrix2i>)));
515  (alignedboxRotatable<AlignedBox3i, Matrix3i>(AlignedBox3i(), &rotate3DZAxisIntegral<int, Matrix3i>)));
516 
518  }
521 }
Rotation rotate3DZAxis(Scalar angle)
Definition: geo_alignedbox.cpp:186
Rotation rotate4DZWAxis(Scalar angle)
Definition: geo_alignedbox.cpp:197
void specificTest1()
Definition: geo_alignedbox.cpp:441
void alignedboxCastTests(const BoxType &box)
Definition: geo_alignedbox.cpp:416
Rotation rotate2D(Scalar angle)
Definition: geo_alignedbox.cpp:175
void specificTest2()
Definition: geo_alignedbox.cpp:470
static int g_repeat
Definition: main.h:191
#define CALL_SUBTEST_6(FUNC)
Definition: split_test_helper.h:34
#define CALL_SUBTEST_3(FUNC)
Definition: split_test_helper.h:16
#define CALL_SUBTEST_1(FUNC)
Definition: split_test_helper.h:4
#define CALL_SUBTEST_13(FUNC)
Definition: split_test_helper.h:76
#define CALL_SUBTEST_14(FUNC)
Definition: split_test_helper.h:82
#define CALL_SUBTEST_8(FUNC)
Definition: split_test_helper.h:46
#define CALL_SUBTEST_5(FUNC)
Definition: split_test_helper.h:28
#define CALL_SUBTEST_11(FUNC)
Definition: split_test_helper.h:64
#define CALL_SUBTEST_12(FUNC)
Definition: split_test_helper.h:70
#define CALL_SUBTEST_2(FUNC)
Definition: split_test_helper.h:10
#define CALL_SUBTEST_7(FUNC)
Definition: split_test_helper.h:40
#define CALL_SUBTEST_4(FUNC)
Definition: split_test_helper.h:22
#define CALL_SUBTEST_9(FUNC)
Definition: split_test_helper.h:52
#define CALL_SUBTEST_10(FUNC)
Definition: split_test_helper.h:58

References alignedbox(), alignedboxCastTests(), alignedboxTranslatable(), CALL_SUBTEST_1, CALL_SUBTEST_10, CALL_SUBTEST_11, CALL_SUBTEST_12, CALL_SUBTEST_13, CALL_SUBTEST_14, CALL_SUBTEST_2, CALL_SUBTEST_3, CALL_SUBTEST_4, CALL_SUBTEST_5, CALL_SUBTEST_6, CALL_SUBTEST_7, CALL_SUBTEST_8, CALL_SUBTEST_9, Eigen::g_repeat, i, rotate2D(), rotate3DZAxis(), rotate4DZWAxis(), specificTest1(), and specificTest2().

◆ kill_extra_precision()

template<typename T >
EIGEN_DONT_INLINE void kill_extra_precision ( T )
19  {
20  // This one worked but triggered a warning:
21  /* eigen_assert((void*)(&x) != (void*)0); */
22  // An alternative could be:
23  /* volatile T tmp = x; */
24  /* x = tmp; */
25 }

Referenced by alignedbox().

◆ randomRotationMatrix()

template<typename MatrixType >
MatrixType randomRotationMatrix ( )
204  {
205  // algorithm from
206  // https://www.isprs-ann-photogramm-remote-sens-spatial-inf-sci.net/III-7/103/2016/isprs-annals-III-7-103-2016.pdf
207  const MatrixType rand = MatrixType::Random();
208  const MatrixType q = rand.householderQr().householderQ();
210  const typename MatrixType::Scalar det = (svd.matrixU() * svd.matrixV().transpose()).determinant();
211  MatrixType diag = rand.Identity();
212  diag(MatrixType::RowsAtCompileTime - 1, MatrixType::ColsAtCompileTime - 1) = det;
213  const MatrixType rotation = svd.matrixU() * diag * svd.matrixV().transpose();
214  return rotation;
215 }
cout<< "Here is the matrix m:"<< endl<< m<< endl;JacobiSVD< MatrixXf, ComputeThinU|ComputeThinV > svd(m)
MatrixXf MatrixType
Definition: benchmark-blocking-sizes.cpp:52
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Definition: JacobiSVD.h:500
void determinant(const MatrixType &m)
Definition: determinant.cpp:15
const char const char const char * diag
Definition: level2_impl.h:86
EIGEN_DEVICE_FUNC const Scalar & q
Definition: SpecialFunctionsImpl.h:2019

References determinant(), diag, Eigen::numext::q, and svd().

◆ rotate2D()

template<typename Scalar , typename Rotation >
Rotation rotate2D ( Scalar  angle)
175  {
176  return Rotation2D<Scalar>(angle);
177 }
Represents a rotation/orientation in a 2 dimensional space.
Definition: Rotation2D.h:44

References Jeffery_Solution::angle().

Referenced by EIGEN_DECLARE_TEST().

◆ rotate2DIntegral()

template<typename Scalar , typename Rotation >
Rotation rotate2DIntegral ( typename NumTraits< Scalar >::NonInteger  angle)
180  {
181  typedef typename NumTraits<Scalar>::NonInteger NonInteger;
182  return Rotation2D<NonInteger>(angle).toRotationMatrix().template cast<Scalar>();
183 }
EIGEN_DEVICE_FUNC Matrix2 toRotationMatrix() const
Definition: Rotation2D.h:191

References Jeffery_Solution::angle(), and Eigen::Rotation2D< Scalar_ >::toRotationMatrix().

◆ rotate3DZAxis()

template<typename Scalar , typename Rotation >
Rotation rotate3DZAxis ( Scalar  angle)
186  {
187  return AngleAxis<Scalar>(angle, Matrix<Scalar, 3, 1>(0, 0, 1));
188 }
Represents a 3D rotation as a rotation angle around an arbitrary 3D axis.
Definition: AngleAxis.h:52

References Jeffery_Solution::angle().

Referenced by EIGEN_DECLARE_TEST().

◆ rotate3DZAxisIntegral()

template<typename Scalar , typename Rotation >
Rotation rotate3DZAxisIntegral ( typename NumTraits< Scalar >::NonInteger  angle)
191  {
192  typedef typename NumTraits<Scalar>::NonInteger NonInteger;
193  return AngleAxis<NonInteger>(angle, Matrix<NonInteger, 3, 1>(0, 0, 1)).toRotationMatrix().template cast<Scalar>();
194 }
EIGEN_DEVICE_FUNC Matrix3 toRotationMatrix(void) const
Definition: AngleAxis.h:217

References Jeffery_Solution::angle(), and Eigen::AngleAxis< Scalar_ >::toRotationMatrix().

◆ rotate4DZWAxis()

template<typename Scalar , typename Rotation >
Rotation rotate4DZWAxis ( Scalar  angle)
197  {
198  Rotation result = Matrix<Scalar, 4, 4>::Identity();
199  result.block(0, 0, 3, 3) = rotate3DZAxis<Scalar, AngleAxisd>(angle).toRotationMatrix();
200  return result;
201 }

References Jeffery_Solution::angle().

Referenced by EIGEN_DECLARE_TEST().

◆ specificTest1()

void specificTest1 ( )
441  {
442  Vector2f m;
443  m << -1.0f, -2.0f;
444  Vector2f M;
445  M << 1.0f, 5.0f;
446 
447  typedef AlignedBox2f BoxType;
448  BoxType box(m, M);
449 
450  Vector2f sides = M - m;
451  VERIFY_IS_APPROX(sides, box.sizes());
452  VERIFY_IS_APPROX(sides[1], box.sizes()[1]);
453  VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff());
454  VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff());
455 
456  VERIFY_IS_APPROX(14.0f, box.volume());
457  VERIFY_IS_APPROX(53.0f, box.diagonal().squaredNorm());
458  VERIFY_IS_APPROX(std::sqrt(53.0f), box.diagonal().norm());
459 
460  VERIFY_IS_APPROX(m, box.corner(BoxType::BottomLeft));
461  VERIFY_IS_APPROX(M, box.corner(BoxType::TopRight));
462  Vector2f bottomRight;
463  bottomRight << M[0], m[1];
464  Vector2f topLeft;
465  topLeft << m[0], M[1];
466  VERIFY_IS_APPROX(bottomRight, box.corner(BoxType::BottomRight));
467  VERIFY_IS_APPROX(topLeft, box.corner(BoxType::TopLeft));
468 }
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:50
int * m
Definition: level2_cplx_impl.h:294

References m, sqrt(), and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().

◆ specificTest2()

void specificTest2 ( )
470  {
471  Vector3i m;
472  m << -1, -2, 0;
473  Vector3i M;
474  M << 1, 5, 3;
475 
476  typedef AlignedBox3i BoxType;
477  BoxType box(m, M);
478 
479  Vector3i sides = M - m;
480  VERIFY_IS_APPROX(sides, box.sizes());
481  VERIFY_IS_APPROX(sides[1], box.sizes()[1]);
482  VERIFY_IS_APPROX(sides[1], box.sizes().maxCoeff());
483  VERIFY_IS_APPROX(sides[0], box.sizes().minCoeff());
484 
485  VERIFY_IS_APPROX(42, box.volume());
486  VERIFY_IS_APPROX(62, box.diagonal().squaredNorm());
487 
488  VERIFY_IS_APPROX(m, box.corner(BoxType::BottomLeftFloor));
489  VERIFY_IS_APPROX(M, box.corner(BoxType::TopRightCeil));
490  Vector3i bottomRightFloor;
491  bottomRightFloor << M[0], m[1], m[2];
492  Vector3i topLeftFloor;
493  topLeftFloor << m[0], M[1], m[2];
494  VERIFY_IS_APPROX(bottomRightFloor, box.corner(BoxType::BottomRightFloor));
495  VERIFY_IS_APPROX(topLeftFloor, box.corner(BoxType::TopLeftFloor));
496 }

References m, and VERIFY_IS_APPROX.

Referenced by EIGEN_DECLARE_TEST().