30 #ifndef GEOMETRY_UTILS_H 31 #define GEOMETRY_UTILS_H 110 const VECTOR2<T> absVec { std::abs( aVec.
x ), std::abs( aVec.
y ) };
112 if ( !only45 && absVec.x > absVec.y * 2 )
117 else if ( !only45 && absVec.y > absVec.x * 2 )
122 else if ( absVec.x > absVec.y )
125 newVec.y = std::copysign( aVec.
x, aVec.
y );
129 newVec.x = std::copysign( aVec.
y, aVec.
x );
148 template <
typename in_type,
typename ret_type = in_type,
typename pad_type =
unsigned int,
149 typename =
typename std::enable_if<std::is_unsigned<pad_type>::value>::type>
152 typedef std::numeric_limits<int> coord_limits;
154 long max = coord_limits::max() - aPadding;
157 in_type x = aCoords.
x;
158 in_type y = aCoords.
y;
170 if( !std::is_integral<in_type>() && std::is_integral<ret_type>() )
190 bool ClipLine(
const EDA_RECT *aClipBox,
int &x1,
int &y1,
int &x2,
int &y2 );
199 return std::max( 1.0, aLineWidth );
204 return 3.0 *
dot_mark_len( aLineWidth ) + ( 2.0 * aLineWidth );
212 #endif // #ifndef GEOMETRY_UTILS_H
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
int CircleToEndSegmentDeltaRadius(int aInnerCircleRadius, int aSegCount)
Define a general 2D-vector/point.
bool ClipLine(const EDA_RECT *aClipBox, int &x1, int &y1, int &x2, int &y2)
Test if any part of a line falls within the bounds of a rectangle.
ERROR_LOC
When approximating an arc or circle, should the error be placed on the outside or inside of the curve...
VECTOR2< ret_type > GetClampedCoords(const VECTOR2< in_type > &aCoords, pad_type aPadding=0u)
Clamps a vector to values that can be negated, respecting numeric limits of coordinates data type wit...
~DISABLE_ARC_RADIUS_CORRECTION()
constexpr double dot_mark_len(double aLineWidth)
Dashed and dotted line patterns.
int GetCircleToPolyCorrection(int aMaxError)
constexpr double dash_gap_len(double aLineWidth)
DISABLE_ARC_RADIUS_CORRECTION()
When creating polygons to create a clearance polygonal area, the polygon must be same or bigger than ...
Handle the component boundary box.
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
int GetArcToSegmentCount(int aRadius, int aErrorMax, double aArcAngleDegree)
constexpr double dash_mark_len(double aLineWidth)