30#ifndef GEOMETRY_UTILS_H
31#define GEOMETRY_UTILS_H
112 if( !only45 && absVec.x > ext_type( absVec.y ) * 2 )
117 else if( !only45 && absVec.y > ext_type( absVec.x ) * 2 )
122 else if( absVec.x > absVec.y )
125 newVec.y = std::copysign( aVec.
x, aVec.
y );
130 newVec.x = std::copysign( aVec.
y, aVec.
x );
149template <
typename in_type,
typename ret_type = in_type,
typename pad_type =
unsigned int,
150 typename =
typename std::enable_if<std::is_unsigned<pad_type>::value>::type>
153 typedef std::numeric_limits<int32_t> coord_limits;
155 long long max =
static_cast<long long>( coord_limits::max() ) - aPadding;
156 long long min = -max;
158 in_type x = aCoords.
x;
159 in_type y = aCoords.
y;
171 if( !std::is_integral<in_type>() && std::is_integral<ret_type>() )
191bool ClipLine(
const BOX2I *aClipBox,
int &x1,
int &y1,
int &x2,
int &y2 );
When creating polygons to create a clearance polygonal area, the polygon must be same or bigger than ...
~DISABLE_ARC_RADIUS_CORRECTION()
DISABLE_ARC_RADIUS_CORRECTION()
Define a general 2D-vector/point.
VECTOR2_TRAITS< T >::extended_type extended_type
int GetCircleToPolyCorrection(int aMaxError)
int CircleToEndSegmentDeltaRadius(int aInnerCircleRadius, int aSegCount)
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
bool ClipLine(const BOX2I *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
int GetArcToSegmentCount(int aRadius, int aErrorMax, const EDA_ANGLE &aArcAngle)
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=1u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".