MCPcopy Create free account
hub / github.com/Derious/cuMPC / alignedboxTranslatable

Function alignedboxTranslatable

dependence/eigen-3.4.0/test/geo_alignedbox.cpp:89–174  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

87}
88
89template<typename BoxType> void alignedboxTranslatable(const BoxType& box)
90{
91 typedef typename BoxType::Scalar Scalar;
92 typedef Matrix<Scalar, BoxType::AmbientDimAtCompileTime, 1> VectorType;
93 typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Isometry> IsometryTransform;
94 typedef Transform<Scalar, BoxType::AmbientDimAtCompileTime, Affine> AffineTransform;
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);

Callers 2

alignedboxRotatableFunction · 0.85
EIGEN_DECLARE_TESTFunction · 0.85

Calls 5

alignedboxFunction · 0.85
sizesMethod · 0.80
translationMethod · 0.80
transformMethod · 0.80
dimMethod · 0.45

Tested by

no test coverage detected