119 if( !only45 && absVec.x > ext_type( absVec.y ) * 2 )
124 else if( !only45 && absVec.y > ext_type( absVec.x ) * 2 )
129 else if( absVec.x > absVec.y )
132 newVec.y = std::copysign( aVec.
x, aVec.
y );
137 newVec.x = std::copysign( aVec.
y, aVec.
x );
160 if( absVec.x >= absVec.y )
180template <
typename in_type,
typename ret_type = in_type,
typename pad_type =
unsigned int,
181 typename =
typename std::enable_if<std::is_unsigned<pad_type>::value>::type>
184 typedef std::numeric_limits<int32_t> coord_limits;
186 in_type x = aCoords.
x;
187 in_type y = aCoords.
y;
189 if constexpr( !std::is_floating_point_v<in_type> )
191 int64_t max =
static_cast<int64_t
>( coord_limits::max() ) - aPadding;
193 x = std::clamp<int64_t>(
static_cast<int64_t
>( x ), min, max );
194 y = std::clamp<int64_t>(
static_cast<int64_t
>( y ), min, max );
198 double max =
static_cast<double>( coord_limits::max() ) - aPadding;
200 x = std::clamp<double>(
static_cast<double>( x ), min, max );
201 y = std::clamp<double>(
static_cast<double>( y ), min, max );
204 if constexpr( !std::is_integral_v<in_type> && std::is_integral_v<ret_type> )
222 constexpr T min = std::numeric_limits<int>::min();
223 constexpr T max = std::numeric_limits<int>::max();
225 return aVec.
x > min && aVec.
x < max && aVec.
y > min && aVec.
y < max;
242bool ClipLine(
const BOX2I *aClipBox,
int &x1,
int &y1,
int &x2,
int &y2 );
266bool BoxHitTest(
const BOX2I& aHitter,
const BOX2I& aHittee,
bool aHitteeContained,
int aAccuracy );
291 const VECTOR2I& aHitteeRotationCenter,
bool aHitteeContained );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
~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...
LEADER_MODE
The kind of the leader line.
@ DIRECT
Unconstrained point-to-point.
VECTOR2< T > GetVectorSnapped90(const VECTOR2< T > &aVec)
Snap a vector onto the nearest horizontal or vertical line.
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)
VECTOR2< int32_t > VECTOR2I