43#ifndef LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_SIMPLE_POLYGON_3D_H
44#define LASS_GUARDIAN_OF_INCLUSION_PRIM_AABB_3D_SIMPLE_POLYGON_3D_H
58template <
typename T,
class EP,
class NP>
62 const size_t n = polygon.
size();
63 for (
size_t i = 0; i < n; ++i)
79template <
typename T,
class EP,
class NP,
class MMP>
85 typedef typename TPoint::TVector TVector;
86 typedef typename TPoint::TValue TValue;
89 const TPoint&
min = box.
min();
90 const TPoint&
max = box.
max();
94 plane.getCartesian(normal, d);
106 if (plane.normal().x < 0)
108 std::reverse(p, p + 4);
110 for (
size_t i = 0; i < 4; ++i)
112 p[i].x = -(dot(normal, p[i].position()) + d) / normal.x;
115 m = TVector(1.0, 0.0, 0.0);
125 if (plane.normal().y < 0)
127 std::reverse(p, p + 4);
129 for (
size_t i = 0; i < 4; ++i)
131 p[i].y = -(dot(normal, p[i].position()) + d) / normal.y;
134 m = TVector(0.0, 1.0, 0.0);
144 if (plane.normal().z < 0)
146 std::reverse(p, p + 4);
148 for (
size_t i = 0; i < 4; ++i)
150 p[i].z = -(dot(normal, p[i].position()) + d) / normal.z;
153 m = TVector(0.0, 0.0, 1.0);
156 LASS_ENFORCE_UNREACHABLE;
173template <
typename T,
class EP,
class NP,
class MMP>
177 typedef typename TPoly::TPlane TPlane;
178 typedef typename TPoly::TPoint TPoint;
179 typedef typename TPoly::TVector TVector;
181 const TPoint&
min = box.
min();
182 const TPoint&
max = box.
max();
184 const TVector i(1, 0, 0);
185 TPoly poly =
clip(TPlane(i, -
min.x),
clip(TPlane(-i,
max.x), polygon));
186 const TVector j(0, 1, 0);
188 const TVector k(0, 0, 1);
SimplePolygon3D< T, EP, NP > clip(const Aabb3D< T, MMP > &box, const SimplePolygon3D< T, EP, NP > &polygon)
Clip a polygon to an AABB .
SimplePolygon3D< T, EP, NP > clip(const Aabb3D< T, MMP > &box, const Plane3D< T, EP, NP > &plane)
Clip a plane to an AABB and get a polygon.
const TPoint & min() const
const TPoint & max() const
Aabb3D< T > aabb(const SimplePolygon3D< T, EP, NP > &polygon)
determine axis aligned bounding box of a 3D simple polygon
const XYZ majorAxis() const
determines the major axis of the normal vector.
convex or concave polygon in 3D (not selfintersecting, no holes)
size_t size() const
return number of vertices
set of geometrical primitives
Library for Assembled Shared Sources.