cesium-native  0.41.0
CesiumGeometry::IntersectionTests Class Referencefinal

Functions for computing the intersection between geometries such as rays, planes, triangles, and ellipsoids. More...

#include <CesiumGeometry/IntersectionTests.h>

Static Public Member Functions

static std::optional< glm::dvec3 > rayPlane (const Ray &ray, const Plane &plane) noexcept
 Computes the intersection of a ray and a plane. More...
 
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. More...
 
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. More...
 
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. More...
 
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. If the point is inside, this also outputs the barycentric coordinates for the point. More...
 
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. More...
 
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. More...
 
static std::optional< glm::dvec3 > rayAABB (const Ray &ray, const AxisAlignedBox &aabb)
 Computes the intersection of a ray and an axis aligned bounding box. More...
 
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 parametric hit position. More...
 
static std::optional< glm::dvec3 > rayOBB (const Ray &ray, const OrientedBoundingBox &obb)
 Computes the intersection of a ray and an oriented bounding box. More...
 
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 hit position. More...
 
static std::optional< glm::dvec3 > raySphere (const Ray &ray, const BoundingSphere &sphere)
 Computes the intersection of a ray and a bounding sphere. More...
 
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 position. More...
 

Detailed Description

Functions for computing the intersection between geometries such as rays, planes, triangles, and ellipsoids.

Definition at line 21 of file IntersectionTests.h.

Member Function Documentation

◆ pointInTriangle() [1/3]

static bool CesiumGeometry::IntersectionTests::pointInTriangle ( const glm::dvec2 &  point,
const glm::dvec2 &  triangleVertA,
const glm::dvec2 &  triangleVertB,
const glm::dvec2 &  triangleVertC 
)
staticnoexcept

Determines whether a given point is completely inside a triangle defined by three 2D points.

This function does not check for degeneracy of the triangle.

Parameters
pointThe point to check.
triangleVertAThe first vertex of the triangle.
triangleVertBThe second vertex of the triangle.
triangleVertCThe third vertex of the triangle.
Returns
Whether the point is within the triangle.

◆ pointInTriangle() [2/3]

static bool CesiumGeometry::IntersectionTests::pointInTriangle ( const glm::dvec3 &  point,
const glm::dvec3 &  triangleVertA,
const glm::dvec3 &  triangleVertB,
const glm::dvec3 &  triangleVertC 
)
staticnoexcept

Determines whether a given point is completely inside a triangle defined by three 3D points.

Returns false for degenerate triangles.

Parameters
pointThe point to check.
triangleVertAThe first vertex of the triangle.
triangleVertBThe second vertex of the triangle.
triangleVertCThe third vertex of the triangle.
Returns
Whether the point is within the triangle.

◆ pointInTriangle() [3/3]

static bool CesiumGeometry::IntersectionTests::pointInTriangle ( const glm::dvec3 &  point,
const glm::dvec3 &  triangleVertA,
const glm::dvec3 &  triangleVertB,
const glm::dvec3 &  triangleVertC,
glm::dvec3 &  barycentricCoordinates 
)
staticnoexcept

Determines whether the point is completely inside a triangle defined by three 3D points. If the point is inside, this also outputs the barycentric coordinates for the point.

Returns false for degenerate triangles.

Parameters
pointThe point to check.
triangleVertAThe first vertex of the triangle.
triangleVertBThe second vertex of the triangle.
triangleVertCThe third vertex of the triangle.
Returns
Whether the point is within the triangle.

◆ rayAABB()

static std::optional<glm::dvec3> CesiumGeometry::IntersectionTests::rayAABB ( const Ray ray,
const AxisAlignedBox aabb 
)
static

Computes the intersection of a ray and an axis aligned bounding box.

Parameters
rayThe ray.
aabbThe axis aligned bounding box.
Returns
The point of intersection, or std::nullopt if there is no intersection.

◆ rayAABBParametric()

static std::optional<double> CesiumGeometry::IntersectionTests::rayAABBParametric ( const Ray ray,
const AxisAlignedBox aabb 
)
static

Computes the intersection of an infinite ray and an axis aligned bounding box and returns the parametric hit position.

The return value is positive if the intersection point is in front of the ray origin, negative if it is behind it, or zero if the two points coincide.

Parameters
rayThe ray.
aabbThe axis aligned bounding box.
Returns
optional hit parametric value, if one is detected.

◆ rayEllipsoid()

static std::optional<glm::dvec2> CesiumGeometry::IntersectionTests::rayEllipsoid ( const Ray ray,
const glm::dvec3 &  radii 
)
staticnoexcept

Computes the intersection of a ray and an ellipsoid with the given radii, centered at the origin.

Returns false if any of the radii are 0.

Parameters
rayThe ray.
radiiThe radii of ellipsoid.
Returns
The distances along the ray where it intersects the ellipsoid, or std::nullopt if there are no intersections. X is the entry, and y is the exit.

◆ rayOBB()

static std::optional<glm::dvec3> CesiumGeometry::IntersectionTests::rayOBB ( const Ray ray,
const OrientedBoundingBox obb 
)
static

Computes the intersection of a ray and an oriented bounding box.

Parameters
rayThe ray.
obbThe oriented bounding box.
Returns
The point of intersection, or std::nullopt if there is no intersection.

◆ rayOBBParametric()

static std::optional<double> CesiumGeometry::IntersectionTests::rayOBBParametric ( const Ray ray,
const OrientedBoundingBox obb 
)
static

Computes the intersection of an infinite ray and an oriented bounding box and returns the parametric hit position.

The return parameter is positive if the intersection point is in front of the ray origin, negative if it is behind it, or zero if the two points coincide.

Parameters
rayThe ray.
obbThe oriented bounding box.
Returns
optional hit parametric value, if one is detected.

◆ rayPlane()

static std::optional<glm::dvec3> CesiumGeometry::IntersectionTests::rayPlane ( const Ray ray,
const Plane plane 
)
staticnoexcept

Computes the intersection of a ray and a plane.

Parameters
rayThe ray.
planeThe plane.
Returns
The point of intersection, or std::nullopt if there is no intersection.

◆ raySphere()

static std::optional<glm::dvec3> CesiumGeometry::IntersectionTests::raySphere ( const Ray ray,
const BoundingSphere sphere 
)
static

Computes the intersection of a ray and a bounding sphere.

Parameters
rayThe ray.
sphereThe bounding sphere.
Returns
The point of intersection, or std::nullopt if there is no intersection.

◆ raySphereParametric()

static std::optional<double> CesiumGeometry::IntersectionTests::raySphereParametric ( const Ray ray,
const BoundingSphere sphere 
)
static

Computes the intersection of an infinite ray and a bounding sphere and returns the parametric hit position.

The return parameter is positive if the intersection point is in front of the ray origin, negative if it is behind it, or zero if the two points coincide.

Parameters
rayThe ray.
sphereThe bounding sphere.
Returns
optional hit parametric value, if one is detected.

◆ rayTriangle()

static std::optional<glm::dvec3> CesiumGeometry::IntersectionTests::rayTriangle ( const Ray ray,
const glm::dvec3 &  p0,
const glm::dvec3 &  p1,
const glm::dvec3 &  p2,
bool  cullBackFaces = false 
)
static

Tests if a ray hits a triangle and returns the hit point.

Parameters
rayThe ray.
p0The first vertex of the triangle.
p1The second vertex of the triangle.
p2The third vertex of the triangle.
cullBackFacesIgnore triangles that face away from ray. Front faces use CCW winding order.
Returns
The point of intersection, or std::nullopt if there is no intersection.

◆ rayTriangleParametric()

static std::optional<double> CesiumGeometry::IntersectionTests::rayTriangleParametric ( const Ray ray,
const glm::dvec3 &  p0,
const glm::dvec3 &  p1,
const glm::dvec3 &  p2,
bool  cullBackFaces = false 
)
static

Tests if an infinite ray hits a triangle and returns the parametric hit position.

The return parameter is positive if the intersection point is in front of the ray origin, negative if it is behind it, or zero if the two points coincide.

Parameters
rayThe ray.
p0The first vertex of the triangle.
p1The second vertex of the triangle.
p2The third vertex of the triangle.
cullBackFacesIgnore triangles that face away from ray. Front faces use CCW winding order.
Returns
optional hit parametric value, if one is detected.

The documentation for this class was generated from the following file: