KiCad PCB EDA Suite
Loading...
Searching...
No Matches
convex_hull.cpp File Reference
#include <geometry/convex_hull.h>
#include <geometry/shape_line_chain.h>
#include <geometry/shape_poly_set.h>
#include <math/vector2d.h>
#include <trigo.h>
#include <algorithm>

Go to the source code of this file.

Typedefs

typedef long long coord2_t
 

Functions

static bool compare_point (const VECTOR2I &ref, const VECTOR2I &p)
 
static coord2_t cross_product (const VECTOR2I &O, const VECTOR2I &A, const VECTOR2I &B)
 
void BuildConvexHull (std::vector< VECTOR2I > &aResult, const std::vector< VECTOR2I > &aPoly)
 Calculate the convex hull of a list of points in counter-clockwise order.
 
void BuildConvexHull (std::vector< VECTOR2I > &aResult, const SHAPE_POLY_SET &aPolygons)
 Calculate the convex hull of a SHAPE_POLY_SET.
 
void BuildConvexHull (std::vector< VECTOR2I > &aResult, const SHAPE_POLY_SET &aPolygons, const VECTOR2I &aPosition, const EDA_ANGLE &aRotation)
 Calculate the convex hull (rotated and moved) of a SHAPE_POLY_SET.
 

Typedef Documentation

◆ coord2_t

typedef long long coord2_t

Definition at line 66 of file convex_hull.cpp.

Function Documentation

◆ BuildConvexHull() [1/3]

void BuildConvexHull ( std::vector< VECTOR2I > &  aResult,
const SHAPE_POLY_SET aPolygons 
)

Calculate the convex hull of a SHAPE_POLY_SET.

Parameters
aResultis a vector to store the convex polygon.
aPolygonsis the SHAPE_POLY_SET.

Definition at line 134 of file convex_hull.cpp.

References ANGLE_0, and BuildConvexHull().

◆ BuildConvexHull() [2/3]

void BuildConvexHull ( std::vector< VECTOR2I > &  aResult,
const SHAPE_POLY_SET aPolygons,
const VECTOR2I aPosition,
const EDA_ANGLE aRotation 
)

Calculate the convex hull (rotated and moved) of a SHAPE_POLY_SET.

Parameters
aResultis a vector to store the convex polygon.
aPolygonsis the set of polygons.
aPositionis the final position of the convex hull.
aRotationis the rotation of the convex hull.

Definition at line 140 of file convex_hull.cpp.

References BuildConvexHull(), SHAPE_POLY_SET::COutline(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_POLY_SET::OutlineCount(), SHAPE_LINE_CHAIN::PointCount(), RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ BuildConvexHull() [3/3]

void BuildConvexHull ( std::vector< VECTOR2I > &  aResult,
const std::vector< VECTOR2I > &  aPoly 
)

Calculate the convex hull of a list of points in counter-clockwise order.

Parameters
aResultis a vector to store the convex polygon.
aPolyis the list of points.

Definition at line 87 of file convex_hull.cpp.

References compare_point(), and cross_product().

Referenced by ZONE_FILLER::addKnockout(), BuildConvexHull(), MULTICHANNEL_TOOL::buildRAOutline(), TEARDROP_MANAGER::computeAnchorPoints(), FOOTPRINT::GetBoundingHull(), and DSN::SPECCTRA_DB::makePADSTACK().

◆ compare_point()

static bool compare_point ( const VECTOR2I ref,
const VECTOR2I p 
)
static

Definition at line 70 of file convex_hull.cpp.

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BuildConvexHull().

◆ cross_product()

static coord2_t cross_product ( const VECTOR2I O,
const VECTOR2I A,
const VECTOR2I B 
)
static

Definition at line 79 of file convex_hull.cpp.

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BuildConvexHull().