Horizon
Macros | Functions
geometry_utils.cpp File Reference

a few functions useful in geometry calculations. More...

#include <geometry/geometry_utils.h>

Macros

#define MIN_SEGCOUNT_FOR_CIRCLE   6
 

Functions

int GetArcToSegmentCount (int aRadius, int aErrorMax, double aArcAngleDegree)
 
double GetCircletoPolyCorrectionFactor (int aSegCountforCircle)
 

Detailed Description

a few functions useful in geometry calculations.

Function Documentation

◆ GetArcToSegmentCount()

int GetArcToSegmentCount ( int  aRadius,
int  aErrorMax,
double  aArcAngleDegree 
)
Returns
the number of segments to approximate a arc by segments with a given max error (this number is >= 1)
Parameters
aRadiusis the radius od the circle or arc
aErrorMaxis the max error This is the max distance between the middle of a segment and the circle.
aArcAngleDegreeis the arc angle in degrees

◆ GetCircletoPolyCorrectionFactor()

double GetCircletoPolyCorrectionFactor ( int  aSegCountforCircle)
Returns
the correction factor to approximate a circle by segments
Parameters
aSegCountforCircleis the number of segments to approximate the circle

When creating a polygon from a circle, the polygon is inside the circle. Only corners are on the circle. This is incorrect when building clearance areas of circles, that need to build the equivalent polygon outside the circle The correction factor is a scaling factor to apply to the radius to build a polygon outside the circle (only the middle of each segment is on the circle