NavMap
Loading...
Searching...
No Matches
test_geometry.cpp File Reference
#include <gtest/gtest.h>
#include <Eigen/Core>
#include "navmap_core/Geometry.hpp"
Include dependency graph for test_geometry.cpp:

Classes

struct  AABB
 Axis-aligned bounding box. More...

Typedefs

using Vec3
 3D vector alias used across NavMap geometry.

Functions

bool ray_triangle_intersect (const Vec3 &orig, const Vec3 &dir, const Vec3 &v0, const Vec3 &v1, const Vec3 &v2, float &t, float &u, float &v)
 Möller–Trumbore ray–triangle intersection.
 TEST (Geometry_AABB, ContainsXYWithZEps)
 TEST (Geometry_AABB, ExpandPointBoxAxis)
 TEST (Geometry_AABB, IntersectsRayVariants)
 TEST (Geometry_RayTriangle, HitMissEdgeBackfaceParallel)
 TEST (Geometry_RayTriangle, RaysThroughASharedEdgeAlwaysHit)
 TEST (Geometry_TriangleArea, BasicScaledDegenerate)
 TEST (Geometry_TriangleNormal, OrientationAndDegenerate)
float triangle_area (const Vec3 &a, const Vec3 &b, const Vec3 &c)
 Compute the area of a triangle ABC.
Vec3 triangle_normal (const Vec3 &a, const Vec3 &b, const Vec3 &c)
 Compute a unit normal of triangle ABC.

Typedef Documentation

◆ Vec3

using Vec3

3D vector alias used across NavMap geometry.

Function Documentation

◆ ray_triangle_intersect()

bool ray_triangle_intersect ( const Vec3 & orig,
const Vec3 & dir,
const Vec3 & v0,
const Vec3 & v1,
const Vec3 & v2,
float & t,
float & u,
float & v )

Möller–Trumbore ray–triangle intersection.

Solves intersection between a ray (orig + t * dir, t > 0) and triangle (v0, v1, v2). Returns true on hit and outputs:

  • t: parametric distance along the ray (t > 0).
  • u, v: barycentric coordinates (with w = 1 - u - v).
Parameters
origRay origin.
dirRay direction (not necessarily unit length).
v0First triangle vertex.
v1Second triangle vertex.
v2Third triangle vertex.
tOutput ray parameter on hit (> 0).
uOutput barycentric u on hit.
vOutput barycentric v on hit.
Returns
True if the ray intersects the triangle with t > 0.
Warning
Numerical robustness depends on the geometry scale; kEps is set conservatively for typical mapping units (meters).

◆ TEST() [1/7]

TEST ( Geometry_AABB ,
ContainsXYWithZEps  )

◆ TEST() [2/7]

TEST ( Geometry_AABB ,
ExpandPointBoxAxis  )

◆ TEST() [3/7]

TEST ( Geometry_AABB ,
IntersectsRayVariants  )

◆ TEST() [4/7]

TEST ( Geometry_RayTriangle ,
HitMissEdgeBackfaceParallel  )

◆ TEST() [5/7]

TEST ( Geometry_RayTriangle ,
RaysThroughASharedEdgeAlwaysHit  )

◆ TEST() [6/7]

TEST ( Geometry_TriangleArea ,
BasicScaledDegenerate  )

◆ TEST() [7/7]

TEST ( Geometry_TriangleNormal ,
OrientationAndDegenerate  )

◆ triangle_area()

float triangle_area ( const Vec3 & a,
const Vec3 & b,
const Vec3 & c )

Compute the area of a triangle ABC.

Parameters
aFirst vertex (world coordinates).
bSecond vertex (world coordinates).
cThird vertex (world coordinates).
Returns
Triangle area (non-negative).
Note
Uses 0.5 * |(b - a) x (c - a)|.

◆ triangle_normal()

Vec3 triangle_normal ( const Vec3 & a,
const Vec3 & b,
const Vec3 & c )

Compute a unit normal of triangle ABC.

The normal is computed as normalized cross product (b - a) x (c - a). If the triangle is degenerate (near-zero area), returns +Z (0, 0, 1).

Parameters
aFirst vertex (world coordinates).
bSecond vertex (world coordinates).
cThird vertex (world coordinates).
Returns
Unit-length normal or +Z fallback for degenerate triangles.