Horizon
|
a few functions useful in geometry calculations. More...
#include <math/vector2d.h>
#include <cmath>
Go to the source code of this file.
Macros | |
#define | DOT_WIDTH_MILS 0.0254 |
Dashed and dotted line patterns. More... | |
#define | DOT_MARK_LEN(aLineWidth) ( std::max( 1.0, IU_PER_MILS * DOT_WIDTH_MILS - aLineWidth ) ) |
#define | DASH_GAP_LEN(aLineWidth) ( 3.0 * DOT_MARK_LEN( aLineWidth ) + ( 2.0 * aLineWidth ) ) |
#define | DASH_MARK_LEN(aLineWidth) ( std::max( DASH_GAP_LEN( aLineWidth ), 5.0 * DOT_MARK_LEN( aLineWidth ) ) ) |
Functions | |
int | GetArcToSegmentCount (int aRadius, int aErrorMax, double aArcAngleDegree) |
double | GetCircletoPolyCorrectionFactor (int aSegCountforCircle) |
template<typename T > | |
VECTOR2< T > | GetVectorSnapped45 (const VECTOR2< T > &aVec) |
Snap a vector onto the nearest 0, 45 or 90 degree line. More... | |
a few functions useful in geometry calculations.
#define DOT_WIDTH_MILS 0.0254 |
Dashed and dotted line patterns.
Note: these are all macros because they're included from files with different IU definitions.
int GetArcToSegmentCount | ( | int | aRadius, |
int | aErrorMax, | ||
double | aArcAngleDegree | ||
) |
aRadius | is the radius od the circle or arc |
aErrorMax | is the max error This is the max distance between the middle of a segment and the circle. |
aArcAngleDegree | is the arc angle in degrees |
double GetCircletoPolyCorrectionFactor | ( | int | aSegCountforCircle | ) |
aSegCountforCircle | is 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
Snap a vector onto the nearest 0, 45 or 90 degree line.
The magnitude of the vector is NOT kept, instead the co-ordinates are set equal (and/or opposite) or to zero as needed. The effect of this is that if the starting vector is on a square grid, the resulting snapped vector will still be on the same grid.
a | vector to be snapped |