39SEG GetBisectorOfCornerSegments(
const SEG& aSegA,
const SEG& aSegB,
int aLength )
47 const auto getSegVectorPointingAwayFrom = [](
const SEG& aSeg,
50 const int distA = ( aSeg.
A - aPoint ).EuclideanNorm();
51 const int distB = ( aSeg.
B - aPoint ).EuclideanNorm();
55 return ( distA < distB ) ? ( aSeg.
B - aSeg.
A ) : ( aSeg.
A - aSeg.
B );
59 const int maxLen = std::max( aSegA.
Length(), aSegB.
Length() );
60 const VECTOR2I aVecOutward = getSegVectorPointingAwayFrom( aSegA, *corner ).
Resize( maxLen );
61 const VECTOR2I bVecOutward = getSegVectorPointingAwayFrom( aSegB, *corner ).
Resize( maxLen );
62 const VECTOR2I bisectorOutward = aVecOutward + bVecOutward;
64 return SEG( *corner, *corner + bisectorOutward.
Resize( aLength ) );
75 if( line_a_setback == 0 && line_b_setback == 0 )
83 if( aSegA.
Length() < line_a_setback || aSegB.
Length() < line_b_setback )
107 SEG setback_a( *corner, *corner +
VECTOR2I( a_end_pt - *corner ).Resize( line_a_setback ) );
108 SEG setback_b( *corner, *corner +
VECTOR2I( b_end_pt - *corner ).Resize( line_b_setback ) );
115 std::optional<SEG> new_a;
120 std::optional<SEG> new_b;
130 int aDogboneRadius,
bool aAddSlots )
140 const SEG bisector = GetBisectorOfCornerSegments( aSegA, aSegB, aDogboneRadius );
143 const VECTOR2I dogboneCenter = bisector.
B;
148 const CIRCLE circle( dogboneCenter, aDogboneRadius );
150 const std::vector<VECTOR2I> segAIntersections = circle.
Intersect( aSegA );
151 const std::vector<VECTOR2I> segBIntersections = circle.
Intersect( aSegB );
154 static int s_epsilon = 8;
156 const auto getPointNotOnCorner =
157 [&](
const std::vector<VECTOR2I>& aIntersections,
const VECTOR2I& aCorner )
159 std::optional<VECTOR2I> result;
160 for(
const VECTOR2I& pt : aIntersections )
162 if( aCorner.Distance( pt ) > s_epsilon )
171 const std::optional<VECTOR2I> ptOnSegA = getPointNotOnCorner( segAIntersections, *corner );
172 const std::optional<VECTOR2I> ptOnSegB = getPointNotOnCorner( segBIntersections, *corner );
175 if( !ptOnSegA || !ptOnSegB )
180 SHAPE_ARC arc( *ptOnSegA, *corner, *ptOnSegB, 0 );
191 std::optional<SEG> new_a, new_b;
192 if( aOtherPtA != *ptOnSegA )
193 new_a =
SEG{ aOtherPtA, *ptOnSegA };
195 if( aOtherPtB != *ptOnSegB )
196 new_b =
SEG{ aOtherPtB, *ptOnSegB };
199 if( !small_arc_mouth || !aAddSlots )
225 slotArc.
GetP0() + ( dogboneCenter - *corner ),
229 slotArc.
GetP1() + ( dogboneCenter - *corner ),
232 const OPT_VECTOR2I ext_a_intersect = arc_extension_a.Intersect( aSegA );
233 const OPT_VECTOR2I ext_b_intersect = arc_extension_b.Intersect( aSegB );
235 if( !ext_a_intersect || !ext_b_intersect )
244 std::optional<SEG> new_a, new_b;
245 if( aOtherPtA != *ext_a_intersect )
246 new_a =
SEG{ aOtherPtA, *ext_a_intersect };
248 if( aOtherPtB != *ext_b_intersect )
249 new_b =
SEG{ aOtherPtB, *ext_b_intersect };
Represent basic circle geometry with utility geometry functions.
std::vector< VECTOR2I > Intersect(const CIRCLE &aCircle) const
Compute the intersection points between this circle and aCircle.
bool IsHorizontal() const
int Length() const
Return the length (this).
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
EDA_ANGLE GetCentralAngle() const
const VECTOR2I & GetP1() const
const VECTOR2I & GetP0() const
VECTOR2< T > Resize(T aNewLength) const
Return a vector of the same direction, but length specified in aNewLength.
std::optional< CHAMFER_RESULT > ComputeChamferPoints(const SEG &aSegA, const SEG &aSegB, const CHAMFER_PARAMS &aChamferParams)
Compute the chamfer points for a given line pair and chamfer parameters.
std::optional< DOGBONE_RESULT > ComputeDogbone(const SEG &aSegA, const SEG &aSegB, int aDogboneRadius, bool aAddSlots)
Compute the dogbone geometry for a given line pair and dogbone parameters.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
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...
bool PointsAreInSameDirection(const VECTOR2< T > &aPointA, const VECTOR2< T > &aPointB, const VECTOR2< T > &aFrom)
Check that the two given points are in the same direction from some other point.
const VECTOR2I & GetOtherEnd(const SEG &aSeg, const VECTOR2I &aPoint)
Get the end point of the segment that is not the given point.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
std::optional< VECTOR2I > OPT_VECTOR2I
Utility functions for working with shapes.
Parameters that define a simple chamfer operation.
int m_chamfer_setback_b
Chamfer set-back distance along the second line.
int m_chamfer_setback_a
Chamfer set-back distance along the first line.
VECTOR2I GetRotated(const VECTOR2I &aVector, const EDA_ANGLE &aAngle)
Return a new VECTOR2I that is the result of rotating aVector by aAngle.
VECTOR2< int32_t > VECTOR2I
Supplemental functions for working with vectors and simple objects that interact with vectors.