cesium-native 0.43.0
Loading...
Searching...
No Matches
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
10namespace CesiumGeometry {
11class Ray;
12class Plane;
13struct AxisAlignedBox;
14class OrientedBoundingBox;
15class BoundingSphere;
16
21class CESIUMGEOMETRY_API IntersectionTests final {
22public:
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
101 static bool pointInTriangle(
102 const glm::dvec3& point,
103 const glm::dvec3& triangleVertA,
104 const glm::dvec3& triangleVertB,
105 const glm::dvec3& triangleVertC,
106 glm::dvec3& barycentricCoordinates) noexcept;
107
120 static std::optional<glm::dvec3> rayTriangle(
121 const Ray& ray,
122 const glm::dvec3& p0,
123 const glm::dvec3& p1,
124 const glm::dvec3& p2,
125 bool cullBackFaces = false);
126
143 static std::optional<double> rayTriangleParametric(
144 const Ray& ray,
145 const glm::dvec3& p0,
146 const glm::dvec3& p1,
147 const glm::dvec3& p2,
148 bool cullBackFaces = false);
149
158 static std::optional<glm::dvec3>
159 rayAABB(const Ray& ray, const AxisAlignedBox& aabb);
160
173 static std::optional<double>
174 rayAABBParametric(const Ray& ray, const AxisAlignedBox& aabb);
175
184 static std::optional<glm::dvec3>
185 rayOBB(const Ray& ray, const OrientedBoundingBox& obb);
186
199 static std::optional<double>
200 rayOBBParametric(const Ray& ray, const OrientedBoundingBox& obb);
201
210 static std::optional<glm::dvec3>
211 raySphere(const Ray& ray, const BoundingSphere& sphere);
212
225 static std::optional<double>
226 raySphereParametric(const Ray& ray, const BoundingSphere& sphere);
227};
228
229} // namespace CesiumGeometry
A bounding sphere with a center and a radius.
Functions for computing the intersection between geometries such as rays, planes, triangles,...
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< 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...
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 > rayOBB(const Ray &ray, const OrientedBoundingBox &obb)
Computes the intersection of a ray and an oriented bounding box.
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 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< glm::dvec3 > rayAABB(const Ray &ray, const AxisAlignedBox &aabb)
Computes the intersection of a ray and an axis aligned bounding box.
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 > 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 > 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.
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.
An Axis-Aligned Bounding Box (AABB), where the axes of the box are aligned with the axes of the coord...