Horizon
Loading...
Searching...
No Matches
Macros | Functions
geometry_utils.cpp File Reference

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

#include <cstdint>
#include <algorithm>
#include <geometry/geometry_utils.h>
#include <math/util.h>

Macros

#define MIN_SEGCOUNT_FOR_CIRCLE   8
 

Functions

int GetArcToSegmentCount (int aRadius, int aErrorMax, double aArcAngleDegree)
 
int CircleToEndSegmentDeltaRadius (int aRadius, int aSegCount)
 
int GetCircleToPolyCorrection (int aMaxError)
 

Detailed Description

a few functions useful in geometry calculations.

Function Documentation

◆ CircleToEndSegmentDeltaRadius()

int CircleToEndSegmentDeltaRadius ( int  aInnerCircleRadius,
int  aSegCount 
)
Returns
the radius diffence of the circle defined by segments inside the circle and the radius of the circle tangent to the middle of segments (defined by segments outside this circle)
Parameters
aInnerCircleRadiusis the radius of the circle tangent to the middle of segments
aSegCountis the seg count to approximate the circle

◆ 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

◆ GetCircleToPolyCorrection()

int GetCircleToPolyCorrection ( int  aMaxError)
Returns
the radius correction to approximate a circle.
Parameters
aMaxErroris the same error value used to calculate the number of segments.

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.