Utilities
Utilities header only library
GeometryStructures.h
1 /*
2  Copyright (C) Skeletex Research, s.r.o. - All Rights Reserved
3  Unauthorized copying of this file, via any medium is strictly prohibited
4  Proprietary and confidential
5 */
6 #ifndef UTILS_GEOMETRY_STRUCTURES_H
7 #define UTILS_GEOMETRY_STRUCTURES_H
8 #include <stdexcept>
9 
10 #include <glm/glm.hpp>
11 #include <Utils/ExtGLM.h>
12 #include <Utils/Property.h>
13 
14 
15 
17 namespace geom
18 {
20  enum class Axis
21  {
22  x,
23  y,
24  z
25  };
26 
28  static inline glm::vec3 AxisToVec3(const geom::Axis axis)
29  {
30  switch (axis)
31  {
32  case Axis::x:
33  return glm::vec3(1.0f, 0.0f, 0.0f);
34  case Axis::y:
35  return glm::vec3(0.0f, 1.0f, 0.0f);
36  case Axis::z:
37  return glm::vec3(0.0f, 0.0f, 1.0f);
38  }
39  throw std::invalid_argument("Undefined axis symbol.");
40  }
41 
43  const static glm::vec3 Vec3X = AxisToVec3(Axis::x);
45  const static glm::vec3 Vec3Y = AxisToVec3(Axis::y);
47  const static glm::vec3 Vec3Z = AxisToVec3(Axis::z);
48 
50  static inline glm::vec4 AxisToVec4(const geom::Axis axis)
51  {
52  return glm::vec4(geom::AxisToVec3(axis), 0.0f);
53  }
54 
56  const static glm::vec4 Vec4X = AxisToVec4(Axis::x);
58  const static glm::vec4 Vec4Y = AxisToVec4(Axis::y);
60  const static glm::vec4 Vec4Z = AxisToVec4(Axis::z);
61 
62 
63 
65  template <size_t N>
66  struct LineSegment
67  {
68  using Vec = glm::vec<N, float>;
69  Vec point1;
70  Vec point2;
71 
72  LineSegment() = default;
73 
74  LineSegment(const Vec &init_point1, const Vec &init_point2)
75  : point1(init_point1), point2(init_point2)
76  {};
77 
79  float GetLength() const
80  {
81  return glm::distance(point1, point2);
82  };
83 
85  float GetLengthSqr() const
86  {
87  return glm::distance2(point1, point2);
88  };
89 
91  Vec GetDirection() const
92  {
93  return glm::normalize(point2 - point1);
94  };
95 
97  Vec ToVector() const
98  {
99  return point2 - point1;
100  };
101  };
102 
104  struct LineSegment2 : public LineSegment<2>
105  {
106  LineSegment2() = default;
107 
108  LineSegment2(float x1, float y1, float x2, float y2)
109  : LineSegment(Vec(x1, y1), Vec(x2, y2))
110  { };
111 
112  LineSegment2(const Vec &init_point1, const Vec &init_point2)
113  : LineSegment(init_point1, init_point2)
114  {};
115  };
116 
118  struct LineSegment3 : public LineSegment<3>
119  {
120  LineSegment3() = default;
121 
122  LineSegment3(float x1, float y1, float z1, float x2, float y2, float z2)
123  : LineSegment(Vec(x1, y1, z1), Vec(x2, y2, z2))
124  { };
125 
126  LineSegment3(const Vec &init_point1, const Vec &init_point2)
127  : LineSegment(init_point1, init_point2)
128  {};
129  };
130 
132  template <size_t N>
133  struct Line
134  {
135  using Vec = glm::vec<N, float>;
136  Vec point, direction;
137  Line() = default;
138  Line(const Vec &_point, const Vec &_direction)
139  : point(_point), direction(glm::normalize(_direction))
140  {};
141  };
142 
144  using Line2 = Line<2>;
145 
147  using Line3 = Line<3>;
148 
149 
150 
152  template <size_t N>
153  struct Ray
154  {
155  using Vec = glm::vec<N, float>;
156  Vec origin;
157  Vec direction;
158 
159  Ray() = default;
160  Ray(const Vec &init_origin, const Vec &init_direction)
161  : origin(init_origin), direction(init_direction)
162  {};
163  };
164 
166  using Ray2 = Ray<2>;
167 
169  using Ray3 = Ray<3>;
170 
172  template <int N, typename T>
173  struct TSphere
174  {
175  glm::vec<N, T> center = glm::vec<N, T>(0);
176  T radius = 0;
177  TSphere() = default;
178  TSphere(const glm::vec<N, T> &_center, const T _radius)
179  : center(_center), radius(_radius)
180  {};
181  T GetDiameter() const
182  {
183  return static_cast<T>(2) * radius;
184  };
185  void SetDiameter(T value)
186  {
187  radius = value / static_cast<T>(2);
188  };
189  };
190 
193 
196 
198  template <size_t D>
199  struct TTriangle
200  {
201  using Vec = glm::vec<D, float>;
202 
203  Vec points[3];
204 
206  Vec &operator[](size_t point_id)
207  {
208  if (point_id >= D)
209  {
210  throw std::invalid_argument("Triangle index out of range.");
211  }
212  return points[point_id];
213  }
214 
216  const Vec &operator[](size_t point_id) const
217  {
218  if (point_id >= D)
219  {
220  throw std::invalid_argument("Triangle index out of range.");
221  }
222  return points[point_id];
223  }
224 
226  Vec GetCentroid() const
227  {
228  return (points[0] + points[1] + points[2]) / 3.0f;
229  }
230  };
231 
233  struct Triangle2 : public TTriangle<2>
234  {
235  Triangle2() = default;
236 
237  Triangle2(const glm::vec2 &p0, const glm::vec2 &p1, const glm::vec2 &p2)
238  {
239  points[0] = p0;
240  points[1] = p1;
241  points[2] = p2;
242  };
243  };
244 
246  struct Triangle3 : public TTriangle<3>
247  {
248  Triangle3() = default;
249 
250  Triangle3(const glm::vec3 &p0, const glm::vec3 &p1, const glm::vec3 &p2)
251  {
252  points[0] = p0;
253  points[1] = p1;
254  points[2] = p2;
255  };
256 
258  glm::vec3 GetNormal() const
259  {
260  return glm::normalize(glm::cross(points[1] - points[0], points[2] - points[0]));
261  }
262  };
263 
264 
265 
267  template <typename T>
268  struct TRect
269  {
270  using Vec2 = glm::tvec2<T>;
271 
272  Vec2 position = Vec2((T)0);
273  Vec2 position2 = Vec2((T)0);
274 
275  TRect() : x(this), y(this), width(this), height(this), x2(this), y2(this), size(this) {};
276  TRect(const T x1, const T y1, const T x2, const T y2) : TRect()
277  {
278  Set(x1, y1, x2, y2);
279  };
280  TRect(const Vec2 &point1, const Vec2 &point2) : TRect()
281  {
282  Set(point1, point2);
283  };
284 
285  void SetSize(const Vec2 &new_size)
286  {
287  position2 = position + new_size;
288  }
289 
290  TRect(const Vec2 &top_left_origin, const T size_width, const T size_height) : TRect()
291  {
292  position = top_left_origin;
293  SetSize(Vec2(size_width, size_height));
294  };
295 
296  void Set(const TRect &rect)
297  {
298  Set(rect.position, rect.position + rect.size);
299  };
300  void Set(const T t_x1, const T t_y1, const T t_x2, const T t_y2)
301  {
302  position.x = glm::min(t_x1, t_x2);
303  position.y = glm::min(t_y1, t_y2);
304  position2.x = glm::max(t_x1, t_x2);
305  position2.y = glm::max(t_y1, t_y2);
306  };
307  void Set(const Vec2 &point1, const Vec2 &point2)
308  {
309  Set(point1.x, point1.y, point2.x, point2.y);
310  };
311 
312  Vec2 GetSize() const
313  {
314  return position2 - position;
315  }
316  T GetX() const
317  {
318  return position.x;
319  };
320  T GetY() const
321  {
322  return position.y;
323  };
324  T GetWidth() const
325  {
326  return GetSize().x;
327  };
328  T GetHeight() const
329  {
330  return GetSize().y;
331  };
332  T GetX2() const
333  {
334  return position.x + GetSize().x;
335  };
336  T GetY2() const
337  {
338  return position.y + GetSize().y;
339  };
340 
341  void SetX(const T value)
342  {
343  position.x = value;
344  };
345  void SetY(const T value)
346  {
347  position.y = value;
348  };
349  void SetWidth(const T value)
350  {
351  position2.x = position.x + value;
352  };
353  void SetHeight(const T value)
354  {
355  position2.y = position.y + value;
356  };
357  void SetX2(const T value)
358  {
359  position2.x = value;
360  };
361  void SetY2(const T value)
362  {
363  position2.y = value;
364  };
365 
366  Vec2 Center(void) const
367  {
368  return (position + position2) / (T)2;
369  };
370  bool Contains(const Vec2 &point) const
371  {
372  return point.x >= position.x && point.x < GetX2() && point.y >= position.y && point.y < GetY2();
373  }
374  T Area(void) const
375  {
376  return (position2.x - position.x) * (position2.y - position.y);
377  }
378 
379  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetX, &TRect<T>::SetX> x;
380  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetY, &TRect<T>::SetY> y;
381  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetWidth, &TRect<T>::SetWidth> width;
382  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetHeight, &TRect<T>::SetHeight> height;
383  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetX2, &TRect<T>::SetX2> x2;
384  utils::PropertyByValue<TRect<T>, T, &TRect<T>::GetY2, &TRect<T>::SetY2> y2;
385  utils::Property<TRect<T>, Vec2, &TRect<T>::GetSize, &TRect<T>::SetSize> size;
386  };
387 
390 
392  using IRect = TRect<int>;
393 
396 
397 
398 
400  template <int dimensions, typename Type>
401  struct TAabb
402  {
403  using Vec = glm::vec<dimensions, Type, glm::highp>;
404  Vec min = Vec(std::numeric_limits<Type>::max());
405  Vec max = Vec(std::numeric_limits<Type>::lowest());
406 
407  TAabb() {};
408  TAabb(const Vec &corner1, const Vec &corner2)
409  {
410  min = (glm::min)(corner1, corner2);
411  max = (glm::max)(corner1, corner2);
412  };
413 
415  Vec GetSize() const
416  {
417  return max - min;
418  }
419 
421  Vec GetCenter() const
422  {
423  return min + GetSize() / Type(2);
424  }
425 
427  float GetDiagonalSqr() const
428  {
429  return (glm::distance2)(min, max);
430  }
431 
433  float GetDiagonal() const
434  {
435  return (glm::distance)(min, max);
436  }
437 
439  bool IsIncluded(const Vec &point) const
440  {
441  for (int i = 0; i < dimensions; i++)
442  {
443  if (point[i] < min[i] || point[i] > max[i])
444  {
445  return false;
446  }
447  }
448  return true;
449  }
450 
452  bool IsInside(const TAabb &aabb) const
453  {
454  return aabb.IsIncluded(min) && aabb.IsIncluded(max);
455  }
456 
458  void Include(const Vec &point)
459  {
460  min = glm::min(min, point);
461  max = glm::max(max, point);
462  };
463 
466  {
467  min = glm::min(min, aabb.min);
468  max = glm::max(max, aabb.max);
469  };
470 
472  bool IsValid() const
473  {
474  return glm::all(glm::lessThan(min, max));
475  }
476 
479  {
481 
482  result.min = glm::max(min, aabb.min);
483  result.max = glm::min(max, aabb.max);
484 
485  return result;
486  }
487 
489  bool AreIntersected(const TAabb<dimensions, Type> &aabb) const
490  {
491  return
492  aabb.min.x < max.x && min.x < aabb.max.x
493  && aabb.min.y < max.y && min.y < aabb.max.y
494  && aabb.min.z < max.z && min.z < aabb.max.z;
495  }
496 
498  Type Volume()
499  {
500  Vec dim = max - min;
501  Type result = dim[0];
502  for (unsigned char i = 1; i < dimensions; i++)
503  {
504  result *= dim[i];
505  }
506  return result;
507  }
508 
510  void Clear()
511  {
512  min = Vec(std::numeric_limits<Type>::max());
513  max = Vec(std::numeric_limits<Type>::lowest());
514  }
515 
517  void Inflate(float d)
518  {
519  min -= d;
520  max += d;
521  }
522 
523  TAabb<dimensions, Type> &operator+=(const TAabb<dimensions, Type> &other)
524  {
525  min += other.min;
526  max += other.max;
527  return *this;
528  };
529 
530  TAabb<dimensions, Type> &operator+=(const Type &other)
531  {
532  min += other;
533  max += other;
534  return *this;
535  };
536 
537  TAabb<dimensions, Type> &operator+=(const Vec &vector)
538  {
539  min += vector;
540  max += vector;
541  return *this;
542  };
543 
544  TAabb<dimensions, Type> &operator-=(const TAabb<dimensions, Type> &other)
545  {
546  min -= other.min;
547  max -= other.max;
548  return *this;
549  };
550 
551  TAabb<dimensions, Type> &operator-=(const Type &other)
552  {
553  min -= other;
554  max -= other;
555  return *this;
556  };
557 
558  TAabb<dimensions, Type> &operator-=(const Vec &vector)
559  {
560  min -= vector;
561  max -= vector;
562  return *this;
563  };
564 
565  TAabb<dimensions, Type> &operator*=(const Type &factor)
566  {
567  min *= factor;
568  max *= factor;
569  return *this;
570  };
571 
572  TAabb<dimensions, Type> &operator*(const Type &factor)
573  {
574  min *= factor;
575  max *= factor;
576  return *this;
577  };
578 
579  TAabb<dimensions, Type> &operator*=(const Vec &vector)
580  {
581  min *= vector;
582  max *= vector;
583  return *this;
584  };
585 
586  TAabb<dimensions, Type> &operator/=(const Type &divisor)
587  {
588  min /= divisor;
589  max /= divisor;
590  return *this;
591  };
592 
593  TAabb<dimensions, Type> &operator/(const Type &divisor)
594  {
595  min /= divisor;
596  max /= divisor;
597  return *this;
598  };
599 
600  TAabb<dimensions, Type> &operator/=(const Vec &vector)
601  {
602  min /= vector;
603  max /= vector;
604  return *this;
605  };
606 
607  };
608 
611 
614 
615 
616 
618  struct Plane
619  {
621  float distance{ 0.0f };
623  glm::vec3 normal{ 0.0f, 0.0f, 1.0f };
624 
625  Plane() = default;
626  Plane(const glm::vec3 &origin, const glm::vec3 &normal)
627  {
628  this->normal = glm::normalize(normal);
629  this->distance = -glm::dot(normal, -origin);
630  };
631  bool operator==(const Plane &other) const
632  {
633  return (this->distance == other.distance) && (this->normal == other.normal);
634  };
635  bool operator!=(const Plane &other) const
636  {
637  return !(*this == other);
638  };
639  };
640 
641 
642 
644  struct HalfPlane
645  {
649  glm::vec3 direction{ glm::vec3(0.0f, 0.0f, 1.0f) };
650 
651  HalfPlane() = default;
652  HalfPlane(const Line3 &border_line, const glm::vec3 &halfplane_direction)
653  {
654  this->border = border_line;
655  this->direction = halfplane_direction;
656  }
657  };
658 
659 
660 
662  struct Capsule
663  {
667  float radius{ 1.0f };
668 
669  Capsule() = default;
670 
671  Capsule(const LineSegment3 &line_segment, float init_radius)
672  : central(line_segment), radius(init_radius)
673  {};
674 
675  Capsule(const glm::vec3 &point1, const glm::vec3 &point2, float init_radius)
676  : central(point1, point2), radius(init_radius)
677  {};
678  };
679 
680 
681 
684  {
688  float radius1{ 1.0f };
690  float radius2{ 1.0f };
691 
692  ConicalCapsule() = default;
693 
694  ConicalCapsule(const LineSegment3 &line_segment, float init_radius1, const float init_radius2)
695  : central(line_segment), radius1(init_radius1), radius2(init_radius2)
696  {};
697 
698  ConicalCapsule(const glm::vec3 point1, const float init_radius1, const glm::vec3 point2, const float init_radius2)
699  : central(point1, point2), radius1(init_radius1), radius2(init_radius2)
700  {};
701 
708  float GetInterpolatedRadius(float factor) const
709  {
710  factor = glm_ext::Clamp01(factor);
711  return (1.f - factor) * radius1 + factor * radius2;
712  };
713  };
714 
715 
716 
718  class KDop
719  {
720  public:
721 
722  KDop() = delete;
723 
725  void Set(const glm::vec3 *points, const size_t num_of_points)
726  {
727  for (size_t i = 0; i < num_of_points; i++)
728  {
729  for (size_t j = 0; j < axes.size(); j++)
730  {
731  const auto t = glm::dot(points[i], axes[j].direction);
732  axes[j].min = std::min(axes[j].min, t);
733  axes[j].max = std::max(axes[j].max, t);
734  }
735  }
736  }
737 
739  bool IsValid() const
740  {
741  return !axes.empty() && std_ext::AllOf(axes, [](const auto & a) { return a.IsValid(); });
742  }
743 
745  bool AreIntersected(const KDop &other)
746  {
747  for (size_t i = 0; i < axes.size(); i++)
748  {
749  if (axes[i].min > other.axes[i].max || axes[i].max < other.axes[i].min)
750  {
751  return false;
752  }
753  }
754  return true;
755  }
756 
758  bool IsIncluded(const glm::vec3 &point)
759  {
760  for (auto &axis : axes)
761  {
762  auto t = glm::dot(point, axis.direction);
763  if (axis.min > t || axis.max < t)
764  {
765  return false;
766  }
767  }
768  return true;
769  }
770 
771  protected:
772 
773  KDop(const std::vector<glm::vec3> &dirs)
774  {
775  axes.resize(dirs.size());
776  for (size_t i = 0; i < dirs.size(); i++)
777  {
778  axes[i].direction = glm::normalize(dirs[i]);
779  }
780  };
781 
782  private:
783 
784  struct PrincipalAxis
785  {
786  glm::vec3 direction;
787  float min{ std::numeric_limits<float>::max() };
788  float max{ std::numeric_limits<float>::min() };
789  bool IsValid() const
790  {
791  return glm_ext::IsLequal(min, max);
792  }
793  };
794 
795  std::vector<PrincipalAxis> axes;
796  };
797 
799  const static std::vector<glm::vec3> KDOP_3_DIRECTIONS
800  {
801  glm::vec3(1.0, 0.0, 0.0),
802  glm::vec3(0.0, 1.0, 0.0),
803  glm::vec3(0.0, 0.0, 1.0),
804  };
806  const static std::vector<glm::vec3> KDOP_4_DIRECTIONS
807  {
808  glm::vec3(1.0, 1.0, 1.0),
809  glm::vec3(1.0, 1.0, -1.0),
810  glm::vec3(1.0, -1.0, 1.0),
811  glm::vec3(1.0, -1.0, -1.0)
812  };
814  const static std::vector<glm::vec3> KDOP_7_DIRECTIONS
815  {
816  glm::vec3(1.0, 0.0, 0.0),
817  glm::vec3(0.0, 1.0, 0.0),
818  glm::vec3(0.0, 0.0, 1.0),
819 
820  glm::vec3(1.0, 1.0, 1.0),
821  glm::vec3(1.0, 1.0, -1.0),
822  glm::vec3(1.0, -1.0, 1.0),
823  glm::vec3(1.0, -1.0, -1.0)
824  };
826  const static std::vector<glm::vec3> KDOP_13_DIRECTIONS
827  {
828  glm::vec3(1.0, 0.0, 0.0),
829  glm::vec3(0.0, 1.0, 0.0),
830  glm::vec3(0.0, 0.0, 1.0),
831 
832  glm::vec3(1.0, 1.0, 1.0),
833  glm::vec3(1.0, 1.0, -1.0),
834  glm::vec3(1.0, -1.0, 1.0),
835  glm::vec3(1.0, -1.0, -1.0),
836 
837  glm::vec3(0.0, 1.0, 1.0),
838  glm::vec3(0.0, 1.0, -1.0),
839  glm::vec3(1.0, 0.0, 1.0),
840  glm::vec3(1.0, 0.0, -1.0),
841  glm::vec3(1.0, 1.0, 0.0),
842  glm::vec3(1.0, -1.0, 0.0),
843  };
844 
846  class KDop3 : public KDop
847  {
848  public:
849  KDop3() : KDop(KDOP_3_DIRECTIONS)
850  {
851  };
852  };
853 
855  class KDop4 : public KDop
856  {
857  public:
858  KDop4() : KDop(KDOP_4_DIRECTIONS)
859  {
860  };
861  };
862 
864  class KDop7 : public KDop
865  {
866  public:
867  KDop7() : KDop(KDOP_7_DIRECTIONS)
868  {
869  };
870  };
871 
873  class KDop13 : public KDop
874  {
875  public:
876  KDop13() : KDop(KDOP_13_DIRECTIONS)
877  {
878  };
879  };
880 }
881 
882 #endif /* !UTILS_GEOMETRY_STRUCTURES_H */
Vec ToVector() const
Converts the line to the vector from point1 to point2.
Definition: GeometryStructures.h:97
k-DOP bounding volume structure with 3 principal axes. It is essentially AABB.
Definition: GeometryStructures.h:846
void Clear()
Resets min and max to init values.
Definition: GeometryStructures.h:510
void Include(const Vec &point)
Enlarges aabb so that it covers also defined point.
Definition: GeometryStructures.h:458
Definition of a line segment in a 3 dimensional space.
Definition: GeometryStructures.h:118
bool AreIntersected(const TAabb< dimensions, Type > &aabb) const
Checks if aabb has an intersection with defined bounding box.
Definition: GeometryStructures.h:489
k-DOP bounding volume structure with 13 principal axes.
Definition: GeometryStructures.h:873
Type Volume()
Returns volume of bounding box.
Definition: GeometryStructures.h:498
float GetLength() const
Returns length of line segment = distance between point1 and point2.
Definition: GeometryStructures.h:79
Definition of a 2 dimensional triangle.
Definition: GeometryStructures.h:233
float GetInterpolatedRadius(float factor) const
Returns a radius in the specific central part of a capsule.
Definition: GeometryStructures.h:708
Vec GetCenter() const
Returns center point of bounding box.
Definition: GeometryStructures.h:421
void Inflate(float d)
Inflate in all directions.
Definition: GeometryStructures.h:517
Template triangle in an arbitrary dimension.
Definition: GeometryStructures.h:199
float distance
Distance from the origin in the direction of a normal.
Definition: GeometryStructures.h:621
const Vec & operator[](size_t point_id) const
Returns point with a specified index. Calling Triangle[0] is equivalent to Triangle.points[0].
Definition: GeometryStructures.h:216
bool AreIntersected(const KDop &other)
Checks if the k-dop has an intersection with other k-dop.
Definition: GeometryStructures.h:745
Template ray in an arbitrary dimension.
Definition: GeometryStructures.h:153
Vec GetCentroid() const
Returns a centroid of the three triangle points.
Definition: GeometryStructures.h:226
void Include(const TAabb< dimensions, Type > &aabb)
Enlarges aabb so that it covers also area of specified aabb.
Definition: GeometryStructures.h:465
auto AllOf(const C &container, const P &Predicate) -> bool
Simplified wrapper for std::all_of.
Definition: ExtSTD.h:841
Definition of a 3 dimensional capsule with different radiuses at each end.
Definition: GeometryStructures.h:683
bool IsLequal(const glm::vec< N, float > &vec1, const glm::vec< N, float > &vec2, const float epsilon=FLT_EPSILON)
Returns true if all components of vec1 are less or equal then vec2 within defined epsilon threshold...
Definition: ExtGLM.h:364
Line3 border
Line representing border of the half-plane.
Definition: GeometryStructures.h:647
Vec & operator[](size_t point_id)
Returns point with a specified index. Calling Triangle[0] is equivalent to Triangle.points[0].
Definition: GeometryStructures.h:206
Template spheroid of in an arbitrary dimension.
Definition: GeometryStructures.h:173
bool IsValid() const
Checks if structure is valid. Invalid structure may have max < min.
Definition: GeometryStructures.h:472
LineSegment3 central
Central line of a capsule.
Definition: GeometryStructures.h:686
TAabb< dimensions, Type > GetIntersection(const TAabb< dimensions, Type > &aabb) const
Returns smaller bounding box computed as an intersection.
Definition: GeometryStructures.h:478
Definition of a 3 dimensional plane.
Definition: GeometryStructures.h:618
Definition of abstract k-DOP bounding volume structure.
Definition: GeometryStructures.h:718
float GetLengthSqr() const
Returns square length of line segment = square distance between point1 and point2.
Definition: GeometryStructures.h:85
LineSegment3 central
Central line of a capsule.
Definition: GeometryStructures.h:665
Vec GetSize() const
Returns sizing vector.
Definition: GeometryStructures.h:415
bool IsValid() const
Checks if all.
Definition: GeometryStructures.h:739
float GetDiagonalSqr() const
Returns square size of diagonal.
Definition: GeometryStructures.h:427
Definition of a 3 dimensional half-plane.
Definition: GeometryStructures.h:644
Template axis aligned bounding box in an arbitrary dimension.
Definition: GeometryStructures.h:401
Template line in an arbitrary dimension.
Definition: GeometryStructures.h:133
Definition of a line segment in a 2 dimensional space.
Definition: GeometryStructures.h:104
glm::vec3 normal
Orientation of the plane.
Definition: GeometryStructures.h:623
Definition of a 3 dimensional triangle.
Definition: GeometryStructures.h:246
Set of structures for geometry and linear algebra.
Definition: GeometryStructures.h:17
Vec GetDirection() const
Returns direction of the line as a normalized vector from point1 to point2.
Definition: GeometryStructures.h:91
bool IsIncluded(const glm::vec3 &point)
Checks if point is included in range of k-dop.
Definition: GeometryStructures.h:758
genType Clamp01(genType x)
Clamps a value or individual vector components to the range 0-1.
Definition: ExtGLM.h:241
void Set(const glm::vec3 *points, const size_t num_of_points)
Set k-dop so that it covers all specified points.
Definition: GeometryStructures.h:725
glm::vec3 GetNormal() const
Calculates a normal vector of a triangle using counter-clockwise order.
Definition: GeometryStructures.h:258
Axis
Enumeration for axes of a 3 dimensional space.
Definition: GeometryStructures.h:20
k-DOP bounding volume structure with 4 principal axes.
Definition: GeometryStructures.h:855
Template rectangle in an arbitrary dimension.
Definition: GeometryStructures.h:268
Definition of a 3 dimensional capsule.
Definition: GeometryStructures.h:662
k-DOP bounding volume structure with 7 principal axes.
Definition: GeometryStructures.h:864
Template line segment in an arbitrary dimension.
Definition: GeometryStructures.h:66
bool IsIncluded(const Vec &point) const
Checks if point is included in range of bounding box.
Definition: GeometryStructures.h:439
float GetDiagonal() const
Returns size of diagonal.
Definition: GeometryStructures.h:433
bool IsInside(const TAabb &aabb) const
Checks if this bounding box is inside other Aabb.
Definition: GeometryStructures.h:452