GEOM
Computer Graphics Structures library
Geometry.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 GEOM_GEOMETRY_H
7 #define GEOM_GEOMETRY_H
8 
9 #include <Utils/GeometryStructures.h>
10 
11 #include <GEOM/API.h>
12 
13 namespace geom
14 {
16  template <typename T>
17  void InflateRectangle(geom::TRect<T> &rect, const T margin)
18  {
19  rect.x -= margin;
20  rect.y -= margin;
21  rect.width += static_cast<T>(2) * margin;
22  rect.height += static_cast<T>(2) * margin;
23  }
24 
26  template <typename T>
27  void DeflateRectangle(geom::TRect<T> &rect, const T margin)
28  {
29  rect.x += margin;
30  rect.y += margin;
31  rect.width -= static_cast<T>(2) * margin;
32  rect.height -= static_cast<T>(2) * margin;
33  }
34 
36  GEOM_API Plane FitPlane(const std::vector<glm::vec3> &points);
37 
39  GEOM_API glm::vec3 GetCentroid(const std::vector<glm::vec3> &points);
40 
48  GEOM_API float GetProjectionParameter(const glm::vec3 &point, const geom::LineSegment3 &line_segment);
49 
57  GEOM_API float GetProjectionParameterClamped(const glm::vec3 &point, const geom::LineSegment3 &line_segment);
58 
60  GEOM_API float GetOrientedDistance(const glm::vec3 &point, const Plane &plane);
61 
63  GEOM_API float GetDistance(const glm::vec3 &point, const geom::LineSegment3 &line);
64 
66  GEOM_API float GetDistance(const glm::vec3 &point, const Plane &plane);
67 
69  GEOM_API float GetDistance(const glm::vec3 &point, const geom::Line3 &line);
70 
75  GEOM_API float GetDistance(const glm::vec3 &point, const ConicalCapsule &conical_capsuile);
76 
78  GEOM_API glm::vec3 GetProjection(const glm::vec3 &point, const Plane &plane);
79 
81  GEOM_API glm::vec3 GetProjection(const glm::vec3 &point, const LineSegment3 &line_segment);
82 
84  GEOM_API glm::vec3 GetProjection(const glm::vec3 &point, const Line3 &line);
85 
87  GEOM_API glm::vec3 GetProjection(const glm::vec3 &point, const ConicalCapsule &capsule);
88 
90  GEOM_API std::optional<glm::vec2> GetIntersection(const geom::Line2 &line1, const geom::Line2 &line2);
91 
92  GEOM_API bool GetIntersection(const geom::Line2 &line1, const geom::Line2 &line2, glm::vec2 *out_intersection_point);
93  GEOM_API bool GetIntersection(const geom::Line3 &line, const geom::Plane &plane, glm::vec3 *out_intersection_point);
94  GEOM_API bool GetIntersection(const geom::LineSegment3 &linesegment, const geom::Plane &plane, glm::vec3 *out_intersection_point);
95  GEOM_API bool GetIntersection(const geom::Line3 &line, const geom::HalfPlane &half_plane, glm::vec3 *out_intersection_point);
96  GEOM_API bool GetIntersection(const geom::LineSegment3 &linesegment, const geom::HalfPlane &half_plane, glm::vec3 *out_intersection_point);
97  GEOM_API bool GetIntersection(const geom::Triangle3 &triangle, const geom::HalfPlane &halfplane, geom::LineSegment3 *out_intersection = nullptr);
98  GEOM_API bool GetIntersection(const geom::Line3 &line, const geom::Aabb3 &aabb);
99 
100  GEOM_API glm::vec3 Barycentric(const glm::vec3 &p, const Triangle3 &triangle);
101 
102  struct CollisionResult
103  {
104  public:
105  bool is_collision;
106  glm::vec3 point1;
107  glm::vec3 point2;
108  float param1;
109  float param2;
110  float depth;
111  };
112 
113  GEOM_API CollisionResult GetCollision(const geom::Capsule &capsule_1, const geom::Capsule &capsule_2);
114 
115  GEOM_API bool IsTriangleFacingToPoint(const glm::vec3 &point, const geom::Triangle3 &triangle);
116 }
117 #endif /* !GEOM_GEOMETRY_H */
Definition: Constructors.h:9