Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::ConvexPolygonDistanceGJK Class Reference

Distance between two closed convex polygons using GJK. More...

#include <geom_algorithms.H>

Collaboration diagram for Aleph::ConvexPolygonDistanceGJK:
[legend]

Classes

struct  ClosestSimplexResult
 
struct  Result
 Holds the results of the distance computation. More...
 
struct  SupportPoint
 A point in the Minkowski difference and its source components. More...
 

Public Member Functions

Result operator() (const Polygon &p, const Polygon &q) const
 Compute the distance between two closed convex polygons.
 

Static Private Member Functions

static double to_double (const Geom_Number &v)
 
static double dot2 (const double ax, const double ay, const double bx, const double by) noexcept
 
static double norm2 (const double x, const double y) noexcept
 
static Point point_from_double (const double x, const double y)
 
static Point lerp_point (const Point &a, const Point &b, const double t)
 
static Point centroid_of (const Array< Point > &v)
 
static SupportPoint support (const Array< Point > &p, const Array< Point > &q, const double dx, const double dy)
 
static bool polygons_intersect_or_contain (const Polygon &p, const Polygon &q)
 
static ClosestSimplexResult closest_from_simplex (const std::vector< SupportPoint > &simplex)
 
static Result exact_refine_disjoint (const Polygon &p, const Polygon &q, const Array< Point > &pv, const Array< Point > &qv)
 

Static Private Attributes

static constexpr size_t kMaxIters = 64
 
static constexpr double kEps = 1e-12
 

Detailed Description

Distance between two closed convex polygons using GJK.

The algorithm runs a 2D GJK loop on the Minkowski difference to detect overlap and drive the search direction. For robust witness output, disjoint cases are refined with exact point-to-segment checks.

Requirements

  • Both polygons must be closed and convex with >= 3 vertices.

Complexity

  • GJK phase: O((n + m) * k), where k is the number of iterations.
  • Refinement (disjoint): O(n * m).

Definition at line 7551 of file geom_algorithms.H.

Member Function Documentation

◆ centroid_of()

static Point Aleph::ConvexPolygonDistanceGJK::centroid_of ( const Array< Point > &  v)
inlinestaticprivate

Definition at line 7625 of file geom_algorithms.H.

References Aleph::Array< T >::size().

Referenced by operator()().

◆ closest_from_simplex()

◆ dot2()

static double Aleph::ConvexPolygonDistanceGJK::dot2 ( const double  ax,
const double  ay,
const double  bx,
const double  by 
)
inlinestaticprivatenoexcept

Definition at line 7598 of file geom_algorithms.H.

References Aleph::divide_and_conquer_partition_dp().

Referenced by closest_from_simplex(), norm2(), and support().

◆ exact_refine_disjoint()

static Result Aleph::ConvexPolygonDistanceGJK::exact_refine_disjoint ( const Polygon p,
const Polygon q,
const Array< Point > &  pv,
const Array< Point > &  qv 
)
inlinestaticprivate

◆ lerp_point()

static Point Aleph::ConvexPolygonDistanceGJK::lerp_point ( const Point a,
const Point b,
const double  t 
)
inlinestaticprivate

◆ norm2()

static double Aleph::ConvexPolygonDistanceGJK::norm2 ( const double  x,
const double  y 
)
inlinestaticprivatenoexcept

Definition at line 7604 of file geom_algorithms.H.

References dot2(), and y.

Referenced by closest_from_simplex(), and operator()().

◆ operator()()

Result Aleph::ConvexPolygonDistanceGJK::operator() ( const Polygon p,
const Polygon q 
) const
inline

◆ point_from_double()

static Point Aleph::ConvexPolygonDistanceGJK::point_from_double ( const double  x,
const double  y 
)
inlinestaticprivate

Definition at line 7609 of file geom_algorithms.H.

References y.

Referenced by closest_from_simplex(), and lerp_point().

◆ polygons_intersect_or_contain()

static bool Aleph::ConvexPolygonDistanceGJK::polygons_intersect_or_contain ( const Polygon p,
const Polygon q 
)
inlinestaticprivate

◆ support()

static SupportPoint Aleph::ConvexPolygonDistanceGJK::support ( const Array< Point > &  p,
const Array< Point > &  q,
const double  dx,
const double  dy 
)
inlinestaticprivate

◆ to_double()

static double Aleph::ConvexPolygonDistanceGJK::to_double ( const Geom_Number v)
inlinestaticprivate

Member Data Documentation

◆ kEps

constexpr double Aleph::ConvexPolygonDistanceGJK::kEps = 1e-12
staticconstexprprivate

Definition at line 7591 of file geom_algorithms.H.

Referenced by closest_from_simplex(), and operator()().

◆ kMaxIters

constexpr size_t Aleph::ConvexPolygonDistanceGJK::kMaxIters = 64
staticconstexprprivate

Definition at line 7590 of file geom_algorithms.H.

Referenced by operator()().


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