46 return ( aSeg.
A == aPoint ) ? aSeg.
B : aSeg.
A;
52 if( aSegA.
A == aSegB.
A || aSegA.
A == aSegB.
B )
56 else if( aSegA.
B == aSegB.
A || aSegA.
B == aSegB.
B )
67 const std::array<VECTOR2I, 4> corners = {
75 SEG{ corners[0], corners[1] },
76 SEG{ corners[1], corners[2] },
77 SEG{ corners[2], corners[3] },
78 SEG{ corners[3], corners[0] },
137 std::optional<VECTOR2I> ptA, ptB;
139 for(
const SEG& boxSeg : boxSegs )
149 if( !ptA || *intersection == *ptA )
163 return SEG( *ptA, *ptB );
168 if( ptA && *ptA != aRay.
GetStart() )
183 std::optional<VECTOR2I> ptA, ptB;
185 for(
const SEG& boxSeg : boxSegs )
190 if( intersection && boxSeg.Contains( *intersection ) )
193 if( !ptA || *intersection == *ptA )
208 return SEG( *ptA, *ptB );
243 default: wxFAIL_MSG(
"Invalid direction" );
return SHAPE_ARC();
277 default: wxFAIL_MSG(
"Invalid direction" );
299 return nw +
VECTOR2I( -aOutset, -aOutset );
307 wxFAIL_MSG(
"Invalid direction" );
316 std::vector<TYPED_POINT2I> pts;
331 pt.m_point += aCircle.
Center;
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
Directions
Available directions, there are 8 of them, as on a rectilinear map (north = up) + an extra undefined ...
OPT_VECTOR2I Intersect(const SEG &aSeg) const
const VECTOR2I & GetStart() const
Get the start point of the ray.
OPT_VECTOR2I Intersect(const SEG &aOther) const
SEG Reversed() const
Returns the center point of the line.
const VECTOR2I & GetPosition() const
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
VECTOR2I GetPoint(const SHAPE_RECT &aRect, DIRECTION_45::Directions aDir, int aOutset=0)
Get the point on a rectangle that corresponds to a given direction.
std::vector< TYPED_POINT2I > GetCircleKeyPoints(const CIRCLE &aCircle, bool aIncludeCenter)
Get key points of an CIRCLE.
OPT_VECTOR2I GetSharedEndpoint(const SEG &aSegA, const SEG &aSegB)
Get the shared endpoint of two segments, if it exists, or std::nullopt if the segments are not connec...
std::vector< SEG > GetSegsInDirection(const BOX2I &aBox, DIRECTION_45::Directions aDir)
Get the segments of a box that are in the given direction.
SEG NormalisedSeg(const SEG &aSeg)
Returns a SEG such that the start point is smaller or equal in x and y compared to the end point.
std::array< SEG, 4 > BoxToSegs(const BOX2I &aBox)
Decompose a BOX2 into four segments.
std::optional< SEG > ClipHalfLineToBox(const HALF_LINE &aRay, const BOX2I &aBox)
Get the segment of a half-line that is inside a box, if any.
std::optional< SEG > ClipLineToBox(const LINE &aLine, const BOX2I &aBox)
Get the segment of a line that is inside a box, if any.
SHAPE_ARC MakeArcCw180(const VECTOR2I &aCenter, int aRadius, DIRECTION_45::Directions aDir)
Get a SHAPE_ARC representing a 180-degree arc in the clockwise direction with the midpoint in the giv...
SHAPE_ARC MakeArcCw90(const VECTOR2I &aCenter, int aRadius, DIRECTION_45::Directions aDir)
Get a SHAPE_ARC representing a 90-degree arc in the clockwise direction with the midpoint in the give...
const VECTOR2I & GetOtherEnd(const SEG &aSeg, const VECTOR2I &aPoint)
Get the end point of the segment that is not the given point.
@ PT_CENTER
The point is the center of something.
@ PT_QUADRANT
The point is on a quadrant of a circle (N, E, S, W points).
std::optional< VECTOR2I > OPT_VECTOR2I
Utility functions for working with shapes.
VECTOR2< int32_t > VECTOR2I
constexpr int LexicographicalCompare(const VECTOR2< T > &aA, const VECTOR2< T > &aB)