cesium-native  0.41.0
IntersectionTests.h
1 #pragma once
2 
3 #include "Library.h"
4 
5 #include <glm/vec2.hpp>
6 #include <glm/vec3.hpp>
7 
8 #include <optional>
9 
10 namespace CesiumGeometry {
11 class Ray;
12 class Plane;
13 struct AxisAlignedBox;
14 class OrientedBoundingBox;
15 class BoundingSphere;
16 
21 class CESIUMGEOMETRY_API IntersectionTests final {
22 public:
31  static std::optional<glm::dvec3>
32  rayPlane(const Ray& ray, const Plane& plane) noexcept;
33 
47  static std::optional<glm::dvec2>
48  rayEllipsoid(const Ray& ray, const glm::dvec3& radii) noexcept;
49 
62  static bool pointInTriangle(
63  const glm::dvec2& point,
64  const glm::dvec2& triangleVertA,
65  const glm::dvec2& triangleVertB,
66  const glm::dvec2& triangleVertC) noexcept;
67 
80  static bool pointInTriangle(
81  const glm::dvec3& point,
82  const glm::dvec3& triangleVertA,
83  const glm::dvec3& triangleVertB,
84  const glm::dvec3& triangleVertC) noexcept;
85 
99  static bool pointInTriangle(
100  const glm::dvec3& point,
101  const glm::dvec3& triangleVertA,
102  const glm::dvec3& triangleVertB,
103  const glm::dvec3& triangleVertC,
104  glm::dvec3& barycentricCoordinates) noexcept;
105 
118  static std::optional<glm::dvec3> rayTriangle(
119  const Ray& ray,
120  const glm::dvec3& p0,
121  const glm::dvec3& p1,
122  const glm::dvec3& p2,
123  bool cullBackFaces = false);
124 
141  static std::optional<double> rayTriangleParametric(
142  const Ray& ray,
143  const glm::dvec3& p0,
144  const glm::dvec3& p1,
145  const glm::dvec3& p2,
146  bool cullBackFaces = false);
147 
156  static std::optional<glm::dvec3>
157  rayAABB(const Ray& ray, const AxisAlignedBox& aabb);
158 
171  static std::optional<double>
172  rayAABBParametric(const Ray& ray, const AxisAlignedBox& aabb);
173 
182  static std::optional<glm::dvec3>
183  rayOBB(const Ray& ray, const OrientedBoundingBox& obb);
184 
197  static std::optional<double>
198  rayOBBParametric(const Ray& ray, const OrientedBoundingBox& obb);
199 
208  static std::optional<glm::dvec3>
209  raySphere(const Ray& ray, const BoundingSphere& sphere);
210 
223  static std::optional<double>
224  raySphereParametric(const Ray& ray, const BoundingSphere& sphere);
225 };
226 
227 } // namespace CesiumGeometry
A bounding sphere with a center and a radius.
Functions for computing the intersection between geometries such as rays, planes, triangles,...
static std::optional< glm::dvec3 > raySphere(const Ray &ray, const BoundingSphere &sphere)
Computes the intersection of a ray and a bounding sphere.
static std::optional< glm::dvec3 > rayPlane(const Ray &ray, const Plane &plane) noexcept
Computes the intersection of a ray and a plane.
static bool pointInTriangle(const glm::dvec3 &point, const glm::dvec3 &triangleVertA, const glm::dvec3 &triangleVertB, const glm::dvec3 &triangleVertC) noexcept
Determines whether a given point is completely inside a triangle defined by three 3D points.
static std::optional< glm::dvec3 > rayOBB(const Ray &ray, const OrientedBoundingBox &obb)
Computes the intersection of a ray and an oriented bounding box.
static std::optional< double > rayAABBParametric(const Ray &ray, const AxisAlignedBox &aabb)
Computes the intersection of an infinite ray and an axis aligned bounding box and returns the paramet...
static std::optional< glm::dvec3 > rayTriangle(const Ray &ray, const glm::dvec3 &p0, const glm::dvec3 &p1, const glm::dvec3 &p2, bool cullBackFaces=false)
Tests if a ray hits a triangle and returns the hit point.
static bool pointInTriangle(const glm::dvec3 &point, const glm::dvec3 &triangleVertA, const glm::dvec3 &triangleVertB, const glm::dvec3 &triangleVertC, glm::dvec3 &barycentricCoordinates) noexcept
Determines whether the point is completely inside a triangle defined by three 3D points....
static std::optional< double > rayTriangleParametric(const Ray &ray, const glm::dvec3 &p0, const glm::dvec3 &p1, const glm::dvec3 &p2, bool cullBackFaces=false)
Tests if an infinite ray hits a triangle and returns the parametric hit position.
static bool pointInTriangle(const glm::dvec2 &point, const glm::dvec2 &triangleVertA, const glm::dvec2 &triangleVertB, const glm::dvec2 &triangleVertC) noexcept
Determines whether a given point is completely inside a triangle defined by three 2D points.
static std::optional< double > rayOBBParametric(const Ray &ray, const OrientedBoundingBox &obb)
Computes the intersection of an infinite ray and an oriented bounding box and returns the parametric ...
static std::optional< glm::dvec3 > rayAABB(const Ray &ray, const AxisAlignedBox &aabb)
Computes the intersection of a ray and an axis aligned bounding box.
static std::optional< glm::dvec2 > rayEllipsoid(const Ray &ray, const glm::dvec3 &radii) noexcept
Computes the intersection of a ray and an ellipsoid with the given radii, centered at the origin.
static std::optional< double > raySphereParametric(const Ray &ray, const BoundingSphere &sphere)
Computes the intersection of an infinite ray and a bounding sphere and returns the parametric hit pos...
A bounding volume defined as a closed and convex cuboid with any orientation.
A plane in Hessian Normal Format.
Definition: Plane.h:12
A ray that extends infinitely from the provided origin in the provided direction.
Definition: Ray.h:14
Basic geometry classes for Cesium.