45 friend inline std::ostream&
operator<<( std::ostream& aStream,
const SEG& aSeg );
63 SEG(
int aX1,
int aY1,
int aX2,
int aY2 ) :
115 return (
A == aSeg.
A &&
B == aSeg.
B) ;
120 return (
A != aSeg.
A ||
B != aSeg.
B);
145 const ecoord det = (
B -
A ).Cross( aP -
A );
147 return det < 0 ? -1 : ( det > 0 ? 1 : 0 );
210 bool aLines =
false )
const;
241 bool Collide(
const SEG& aSeg,
int aClearance,
int* aActual =
nullptr )
const;
267 qC = -qA *
A.x - qB *
A.y;
284 return ( d1 <= 1 && d2 <= 1 );
293 if( aSeg.
A == aSeg.
B )
295 if(
A == aSeg.
A ||
B == aSeg.
A )
316 if( aSeg.
A == aSeg.
B )
335 return (
A -
B ).EuclideanNorm();
340 return (
A -
B ).SquaredEuclideanNorm();
371 return A + (
B -
A ) / 2;
385 bool intersects(
const SEG& aSeg,
bool aIgnoreEndpoints =
false,
bool aLines =
false,
398 return d.
Dot( aP -
A);
403 aStream <<
"[ " << aSeg.
A <<
" - " << aSeg.
B <<
" ]";
const VECTOR2I ReflectPoint(const VECTOR2I &aP) const
Reflect a point using this segment as axis.
int LineDistance(const VECTOR2I &aP, bool aDetermineSide=false) const
Return the closest Euclidean distance between point aP and the line defined by the ends of segment (t...
ecoord SquaredDistance(const SEG &aSeg) const
bool intersects(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false, VECTOR2I *aPt=nullptr) const
int m_index
< index within the parent shape (used when m_is_local == false)
VECTOR2I::extended_type ecoord
void CanonicalCoefs(ecoord &qA, ecoord &qB, ecoord &qC) const
SEG(const VECTOR2I &aA, const VECTOR2I &aB, int aIndex)
Create a segment between (aA) and (aB), referenced to a multi-segment shape.
friend std::ostream & operator<<(std::ostream &aStream, const SEG &aSeg)
SEG & operator=(const SEG &aSeg)
int Index() const
Return the index of this segment in its parent shape (applicable only to non-local segments).
const VECTOR2I NearestPoint(const VECTOR2I &aP) const
Compute a point on the segment (this) that is closest to point aP.
bool Intersects(const SEG &aSeg) const
int Length() const
Return the length (this).
SEG(int aX1, int aY1, int aX2, int aY2)
Create a segment between (aX1, aY1) and (aX2, aY2).
OPT_VECTOR2I Intersect(const SEG &aSeg, bool aIgnoreEndpoints=false, bool aLines=false) const
Compute intersection point of segment (this) with segment aSeg.
static SEG::ecoord Square(int a)
bool Collide(const SEG &aSeg, int aClearance, int *aActual=nullptr) const
bool ApproxParallel(const SEG &aSeg, int aDistanceThreshold=1) const
SEG()
Create an empty (0, 0) segment.
bool Collinear(const SEG &aSeg) const
Check if segment aSeg lies on the same line as (this).
SEG ParallelSeg(const VECTOR2I &aP) const
Compute a segment parallel to this one, passing through point aP.
ecoord TCoef(const VECTOR2I &aP) const
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
ecoord SquaredLength() const
bool operator==(const SEG &aSeg) const
bool ApproxPerpendicular(const SEG &aSeg) const
bool ApproxCollinear(const SEG &aSeg, int aDistanceThreshold=1) const
bool operator<(const SEG &aSeg) const
bool Overlaps(const SEG &aSeg) const
bool mutualDistanceSquared(const SEG &aSeg, ecoord &aD1, ecoord &aD2) const
bool operator!=(const SEG &aSeg) const
bool NearestPoints(const SEG &aSeg, VECTOR2I &aPtA, VECTOR2I &aPtB, int64_t &aDistSq) const
Compute closest points between this segment and aSeg.
int Distance(const SEG &aSeg) const
Compute minimum Euclidean distance to segment aSeg.
bool ccw(const VECTOR2I &aA, const VECTOR2I &aB, const VECTOR2I &aC) const
bool Contains(const SEG &aSeg) const
SEG(const SEG &aSeg)
Copy constructor.
VECTOR2I LineProject(const VECTOR2I &aP) const
Compute the perpendicular projection point of aP on a line passing through ends of the segment.
SEG PerpendicularSeg(const VECTOR2I &aP) const
Compute a segment perpendicular to this one, passing through point aP.
int Side(const VECTOR2I &aP) const
Determine on which side of directed line passing via segment ends point aP lies.
EDA_ANGLE Angle(const SEG &aOther) const
Determine the smallest angle between two segments.
SEG(const VECTOR2I &aA, const VECTOR2I &aB)
Create a segment between (aA) and (aB).
SEG Reversed() const
Returns the center point of the line.
VECTOR2_TRAITS< int32_t >::extended_type extended_type
constexpr extended_type Dot(const VECTOR2< T > &aVector) const
Compute dot product of self with aVector.
std::ostream & operator<<(std::ostream &aStream, const EDA_TEXT &aText)
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
std::optional< VECTOR2I > OPT_VECTOR2I
VECTOR2I::extended_type ecoord