109 if( !only45 && absVec.x > ext_type( absVec.y ) * 2 )
114 else if( !only45 && absVec.y > ext_type( absVec.x ) * 2 )
119 else if( absVec.x > absVec.y )
122 newVec.y = std::copysign( aVec.
x, aVec.
y );
127 newVec.x = std::copysign( aVec.
y, aVec.
x );
146template <
typename in_type,
typename ret_type = in_type,
typename pad_type =
unsigned int,
147 typename =
typename std::enable_if<std::is_unsigned<pad_type>::value>::type>
150 typedef std::numeric_limits<int32_t> coord_limits;
152 in_type x = aCoords.
x;
153 in_type y = aCoords.
y;
155 if constexpr( !std::is_floating_point_v<in_type> )
157 int64_t max =
static_cast<int64_t
>( coord_limits::max() ) - aPadding;
159 x = std::clamp<int64_t>(
static_cast<int64_t
>( x ), min, max );
160 y = std::clamp<int64_t>(
static_cast<int64_t
>( y ), min, max );
164 double max =
static_cast<double>( coord_limits::max() ) - aPadding;
166 x = std::clamp<double>(
static_cast<double>( x ), min, max );
167 y = std::clamp<double>(
static_cast<double>( y ), min, max );
170 if constexpr( !std::is_integral_v<in_type> && std::is_integral_v<ret_type> )
173 KiROUND<in_type, ret_type>( y,
true ) );
188 constexpr T min = std::numeric_limits<int>::min();
189 constexpr T max = std::numeric_limits<int>::max();
191 return aVec.
x > min && aVec.
x < max && aVec.
y > min && aVec.
y < max;
208bool ClipLine(
const BOX2I *aClipBox,
int &x1,
int &y1,
int &x2,
int &y2 );
232bool BoxHitTest(
const BOX2I& aHitter,
const BOX2I& aHittee,
bool aHitteeContained,
int aAccuracy );
257 const VECTOR2I& aHitteeRotationCenter,
bool aHitteeContained );
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()
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
Define a general 2D-vector/point.
VECTOR2_TRAITS< T >::extended_type extended_type
int GetCircleToPolyCorrection(int aMaxError)
int CircleToEndSegmentDeltaRadius(int aInnerCircleRadius, int aSegCount)
VECTOR2< T > GetVectorSnapped45(const VECTOR2< T > &aVec, bool only45=false)
Snap a vector onto the nearest 0, 45 or 90 degree line.
bool IsVec2SafeXY(const VECTOR2< T > &aVec)
Check if both coordinates of a vector are within the limits of the integer type.
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...
bool ShapeHitTest(const SHAPE_LINE_CHAIN &aHitter, const SHAPE &aHittee, bool aHitteeContained)
Perform a shape-to-shape hit test.
bool BoxHitTest(const VECTOR2I &aHitPoint, const BOX2I &aHittee, int aAccuracy)
Perform a point-to-box hit test.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)