13 #undef NDEBUG // enable assert in release build
15 #include <boost/concept_check.hpp>
27 template<
typename Mesh >
34 typedef typename Geometry::Scalar
Scalar;
46 Point p(1.1f, 2.2f, 3.3f);
60 #pragma GCC diagnostic push
61 #pragma GCC diagnostic ignored "-Wunused-but-set-variable"
67 #pragma GCC diagnostic pop
73 Vector v(4.4f, 5.5f, 6.6f);
94 v1 =
Vector(v1[0], v1[1], 999.0f);
100 v = gt.add_v(v1, v2);
101 v = gt.sub_v(v1, v2);
102 gt.dot_product(v1, v2);
103 gt.cross_product(v1, v2);
106 v2 = gt.scalar_mult(v1, s);
111 v1 = gt.normal(p, p, p);
112 v1 = gt.unit_normal(p, p, p);
113 p = gt.add_pv(p, v1);
114 p = gt.sub_pv(p, v1);
124 #ifndef FEVV_USE_CGAL
129 v1 = GeometryTraits::sub_p< G >(p, p);
130 v1 = GeometryTraits::add_v< G >(v1, v2);
131 v1 = GeometryTraits::sub_v< G >(v1, v2);
132 p = GeometryTraits::add_pv< G >(p, v1);
136 #ifndef FEVV_USE_CGAL
147 template<
typename GeometryTraits >
152 typedef typename GeometryTraits::Scalar Scalar;
155 auto almost_equal_s = [](Scalar s1, Scalar s2, Scalar
epsilon) ->
bool
157 return std::abs(s1 - s2) <=
epsilon;
161 auto almost_equal_p = [almost_equal_s](
Point p1,
Point p2, Scalar
epsilon) ->
bool
163 return almost_equal_s(GeometryTraits::get_x(p1),
164 GeometryTraits::get_x(p2),
166 almost_equal_s(GeometryTraits::get_y(p1),
167 GeometryTraits::get_y(p2),
169 almost_equal_s(GeometryTraits::get_z(p1),
170 GeometryTraits::get_z(p2),
177 return almost_equal_s(v1[0], v2[0],
epsilon) &&
178 almost_equal_s(v1[1], v2[1],
epsilon) &&
179 almost_equal_s(v1[2], v2[2],
epsilon);
183 Vector u(8.3f, -3.2f, -3.8f);
184 Vector v(1.2f, 2.3f, 3.4f);
185 Point p(3.0f, 12.5f, -2.1f);
186 Point q(-1.4f, 4.6f, -1.9f);
187 Point r(-2.6f, 4.7f, 5.8f);
190 Scalar l2 = GeometryTraits::length2(v);
191 assert(almost_equal_s(l2, 18.29f, eps));
193 Scalar l = GeometryTraits::length(v);
194 assert(almost_equal_s(l, 4.276681f, eps));
197 assert(almost_equal_v(n,
Vector(0.280591f, 0.537800f, 0.795009f), eps));
202 assert(almost_equal_v(w,
Vector(4.4f, 7.9f, -0.2f), eps));
204 Scalar l = GeometryTraits::length(p, q);
205 assert(almost_equal_s(l, 9.044888f, eps));
213 GeometryTraits gt(m);
215 Vector n = gt.normal(p, q, r);
216 assert(almost_equal_v(n,
Vector(-60.85f, 33.64f, -9.92f), eps) ||
217 almost_equal_v(n,
Vector(-0.866393f, 0.478972f, -0.141243f), eps) );
220 n = gt.unit_normal(p, q, r);
221 assert(almost_equal_v(n,
Vector(-0.866393f, 0.478972f, -0.141243f), eps));
226 assert(almost_equal_v(w,
Vector(9.5f, -0.9f, -0.4f), eps));
229 assert(almost_equal_s(d, -10.32f, eps));
232 assert(almost_equal_v(w,
Vector(-2.14f, -32.78f, 22.93f), eps));
237 assert(almost_equal_p(a,
Point(4.2f, 14.8f, 1.3f), eps));
240 assert(almost_equal_p(a,
Point(1.8f, 10.2f, -5.5f), eps));
243 assert(almost_equal_v(w,
Vector(-2.814f, -5.3935f, -7.973f), eps));