KiCad PCB EDA Suite
trigo.h File Reference
#include <cmath>
#include <math/vector2d.h>
#include <wx/gdicmn.h>

Go to the source code of this file.

Functions

bool IsPointOnSegment (const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
 Test if aTestPoint is on line defined by aSegStart and aSegEnd. More...
 
bool SegmentIntersectsSegment (const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, const wxPoint &a_p1_l2, const wxPoint &a_p2_l2, wxPoint *aIntersectionPoint=nullptr)
 Test if two lines intersect. More...
 
void RotatePoint (int *pX, int *pY, double angle)
 
void RotatePoint (int *pX, int *pY, int cx, int cy, double angle)
 
void RotatePoint (wxPoint *point, double angle)
 
void RotatePoint (VECTOR2I &point, double angle)
 
void RotatePoint (VECTOR2I &point, const VECTOR2I &centre, double angle)
 
void RotatePoint (wxPoint *point, const wxPoint &centre, double angle)
 
void RotatePoint (double *pX, double *pY, double angle)
 
void RotatePoint (double *pX, double *pY, double cx, double cy, double angle)
 
const VECTOR2I GetArcCenter (const VECTOR2I &aStart, const VECTOR2I &aMid, const VECTOR2I &aEnd)
 Determine the center of an arc or circle given three points on its circumference. More...
 
const VECTOR2D GetArcCenter (const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd)
 
const wxPoint GetArcCenter (const wxPoint &aStart, const wxPoint &aMid, const wxPoint &aEnd)
 
double ArcTangente (int dy, int dx)
 
double EuclideanNorm (const wxPoint &vector)
 Euclidean norm of a 2D vector. More...
 
double EuclideanNorm (const wxSize &vector)
 
double DistanceLinePoint (const wxPoint &linePointA, const wxPoint &linePointB, const wxPoint &referencePoint)
 Compute the distance between a line and a reference point Reference: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html. More...
 
bool HitTestPoints (const wxPoint &pointA, const wxPoint &pointB, double threshold)
 Test, if two points are near each other. More...
 
double CrossProduct (const wxPoint &vectorA, const wxPoint &vectorB)
 Determine the cross product. More...
 
bool TestSegmentHit (const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
 Test if aRefPoint is with aDistance on the line defined by aStart and aEnd. More...
 
double GetLineLength (const wxPoint &aPointA, const wxPoint &aPointB)
 Return the length of a line segment defined by aPointA and aPointB. More...
 
double DEG2RAD (double deg)
 
double RAD2DEG (double rad)
 
double DECIDEG2RAD (double deg)
 
double RAD2DECIDEG (double rad)
 
template<class T >
NormalizeAngle360Max (T Angle)
 Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360. More...
 
template<class T >
NormalizeAngle360Min (T Angle)
 Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0. More...
 
template<class T >
NormalizeAnglePos (T Angle)
 Normalize angle to be in the 0.0 . More...
 
template<class T >
void NORMALIZE_ANGLE_POS (T &Angle)
 
double NormalizeAngleDegreesPos (double Angle)
 Normalize angle to be in the 0.0 . More...
 
void NORMALIZE_ANGLE_DEGREES_POS (double &Angle)
 
double NormalizeAngleRadiansPos (double Angle)
 
double NormalizeAngleDegrees (double Angle, double aMin, double aMax)
 Normalize angle to be aMin < angle <= aMax angle is in degrees. More...
 
template<class T , class T2 >
AddAngles (T a1, T2 a2)
 Add two angles (keeping the result normalized). T2 is here. More...
 
template<class T >
NegateAndNormalizeAnglePos (T Angle)
 
template<class T >
void NEGATE_AND_NORMALIZE_ANGLE_POS (T &Angle)
 
template<class T >
NormalizeAngle90 (T Angle)
 Normalize angle to be in the -90.0 .. 90.0 range. More...
 
template<class T >
void NORMALIZE_ANGLE_90 (T &Angle)
 
template<class T >
NormalizeAngle180 (T Angle)
 Normalize angle to be in the -180.0 .. 180.0 range. More...
 
template<class T >
void NORMALIZE_ANGLE_180 (T &Angle)
 
bool InterceptsPositiveX (double aStartAngle, double aEndAngle)
 Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees). More...
 
bool InterceptsNegativeX (double aStartAngle, double aEndAngle)
 Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees). More...
 
double sindecideg (double r, double a)
 Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians. More...
 
double cosdecideg (double r, double a)
 Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians. More...
 

Function Documentation

◆ AddAngles()

template<class T , class T2 >
T AddAngles ( a1,
T2  a2 
)
inline

Add two angles (keeping the result normalized). T2 is here.

Definition at line 304 of file trigo.h.

305 {
306  a1 += a2;
307  NORMALIZE_ANGLE_POS( a1 );
308  return a1;
309 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257

References NORMALIZE_ANGLE_POS().

Referenced by convertOblong2Segment(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), DXF_PLOTTER::FlashPadOval(), and PLOTTER::sketchOval().

◆ ArcTangente()

double ArcTangente ( int  dy,
int  dx 
)

Definition at line 162 of file trigo.cpp.

163 {
164 
165  /* gcc is surprisingly smart in optimizing these conditions in
166  a tree! */
167 
168  if( dx == 0 && dy == 0 )
169  return 0;
170 
171  if( dy == 0 )
172  {
173  if( dx >= 0 )
174  return 0;
175  else
176  return -1800;
177  }
178 
179  if( dx == 0 )
180  {
181  if( dy >= 0 )
182  return 900;
183  else
184  return -900;
185  }
186 
187  if( dx == dy )
188  {
189  if( dx >= 0 )
190  return 450;
191  else
192  return -1800 + 450;
193  }
194 
195  if( dx == -dy )
196  {
197  if( dx >= 0 )
198  return -450;
199  else
200  return 1800 - 450;
201  }
202 
203  // Of course dy and dx are treated as double
204  return RAD2DECIDEG( atan2( (double) dy, (double) dx ) );
205 }
double RAD2DECIDEG(double rad)
Definition: trigo.h:219

References RAD2DECIDEG().

Referenced by BuildCornersList_S_Shape(), LIB_ARC::CalcEdit(), LIB_ARC::CalcRadiusAngles(), DRC::checkClearancePadToPad(), AM_PRIMITIVE::ConvertShapeToPolygon(), DRC::doTrackDrc(), AR_MATRIX::drawSegmentQcq(), fillArcPOLY(), ARC::GetAngle(), ARC::GetArcAngleEnd(), DRAWSEGMENT::GetArcAngleStart(), ARC::GetArcAngleStart(), GRCSegm(), DRAWSEGMENT::HitTest(), ARC::HitTest(), PCAD2KICAD::PCB_ARC::Parse(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), BRDITEMS_PLOTTER::PlotDrawSegment(), EDGE_MODULE::Print(), DRAWSEGMENT::Print(), PLOTTER::segmentAsOval(), AR_MATRIX::traceArc(), and TransformSegmentToPolygon().

◆ cosdecideg()

double cosdecideg ( double  r,
double  a 
)
inline

Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.

Definition at line 408 of file trigo.h.

409 {
410  return r * cos( DECIDEG2RAD( a ) );
411 }
double DECIDEG2RAD(double deg)
Definition: trigo.h:218

References DECIDEG2RAD().

Referenced by PLOTTER::Arc(), HPGL_PLOTTER::Arc(), PDF_PLOTTER::Arc(), GERBER_PLOTTER::Arc(), PCAD2KICAD::PCB_ARC::Parse(), AR_MATRIX::traceArc(), and AR_MATRIX::traceCircle().

◆ CrossProduct()

double CrossProduct ( const wxPoint vectorA,
const wxPoint vectorB 
)
inline

Determine the cross product.

Parameters
vectorATwo-dimensional vector
vectorBTwo-dimensional vector

Definition at line 182 of file trigo.h.

183 {
184  // As before the cast is to avoid int overflow
185  return (double)vectorA.x * vectorB.y - (double)vectorA.y * vectorB.x;
186 }

References wxPoint::x, and wxPoint::y.

Referenced by LIB_ARC::HitTest().

◆ DECIDEG2RAD()

◆ DEG2RAD()

◆ DistanceLinePoint()

double DistanceLinePoint ( const wxPoint linePointA,
const wxPoint linePointB,
const wxPoint referencePoint 
)
inline

Compute the distance between a line and a reference point Reference: http://mathworld.wolfram.com/Point-LineDistance2-Dimensional.html.

Parameters
linePointAPoint on line
linePointBPoint on line
referencePointReference point

Definition at line 145 of file trigo.h.

148 {
149  // Some of the multiple double casts are redundant. However in the previous
150  // definition the cast was (implicitly) done too late, just before
151  // the division (EuclideanNorm gives a double so from int it would
152  // be promoted); that means that the whole expression were
153  // vulnerable to overflow during int multiplications
154  return fabs( ( double(linePointB.x - linePointA.x) *
155  double(linePointA.y - referencePoint.y) -
156  double(linePointA.x - referencePoint.x ) *
157  double(linePointB.y - linePointA.y) )
158  / EuclideanNorm( linePointB - linePointA ) );
159 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:128

References EuclideanNorm(), wxPoint::x, and wxPoint::y.

Referenced by LIB_POLYLINE::AddCorner().

◆ EuclideanNorm() [1/2]

double EuclideanNorm ( const wxPoint vector)
inline

Euclidean norm of a 2D vector.

Parameters
vectorTwo-dimensional vector
Returns
Euclidean norm of the vector

Definition at line 128 of file trigo.h.

129 {
130  // this is working with doubles
131  return hypot( vector.x, vector.y );
132 }

References wxPoint::x, and wxPoint::y.

Referenced by GRID_HELPER::AlignToArc(), GRID_HELPER::AlignToSegment(), GRID_HELPER::BestSnapAnchor(), BOOST_AUTO_TEST_CASE(), D_PAD::boundingRadius(), BuildCornersList_S_Shape(), PNS::DP_GATEWAYS::buildDpContinuation(), PNS::DP_GATEWAYS::BuildFromPrimitivePair(), PNS::DP_GATEWAYS::BuildGeneric(), PNS::DP_GATEWAYS::BuildOrthoProjections(), LIB_ARC::CalcRadiusAngles(), DRC::checkClearancePadToPad(), DRC::checkMarginToCircle(), PNS::closestProjectedPoint(), Collide(), SHAPE_ARC::Collide(), GRID_HELPER::computeAnchors(), AM_PRIMITIVE::ConvertShapeToPolygon(), MWAVE::CreateMicrowaveInductor(), PNS::DP_PRIMITIVE_PAIR::CursorOrientation(), DistanceLinePoint(), DRC::doTrackDrc(), KIGFX::CAIRO_GAL_BASE::DrawSegment(), DRAWING_TOOL::DrawVia(), PAD_TOOL::EnumeratePads(), PNS::findCoupledVertices(), PNS::DIFF_PAIR_PLACER::findDpPrimitivePair(), gen_arc(), D_PAD::GetBestAnchorPosition(), DRAWSEGMENT::HitTest(), ARC::HitTest(), D_PAD::HitTest(), GEOM_TEST::IsPointAtDistance(), PNS::makeGapVector(), PNS::MEANDERED_LINE::MeanderSegment(), PNS::NODE::NearestObstacle(), PNS::TOPOLOGY::NearestUnconnectedItem(), CONNECTIVITY_DATA::NearestUnconnectedTargets(), compareOriginDistance::operator()(), SHAPE_LINE_CHAIN::compareOriginDistance::operator()(), GPCB_FPL_CACHE::parseMODULE(), SHAPE_LINE_CHAIN::PathLength(), pushoutForce(), PNS::LINE_PLACER::rhMarkObstacles(), PNS::DIFF_PAIR_PLACER::routeHead(), PLOTTER::segmentAsOval(), PNS::LINE::snapDraggedCorner(), PNS::TOOL_BASE::snapToItem(), PNS::DRAGGER::startDragSegment(), TransformArcToPolygon(), TransformOvalToPolygon(), and TransformSegmentToPolygon().

◆ EuclideanNorm() [2/2]

double EuclideanNorm ( const wxSize &  vector)
inline

Definition at line 134 of file trigo.h.

135 {
136  // this is working with doubles, too
137  return hypot( vector.x, vector.y );
138 }

◆ GetArcCenter() [1/3]

const VECTOR2I GetArcCenter ( const VECTOR2I aStart,
const VECTOR2I aMid,
const VECTOR2I aEnd 
)

Determine the center of an arc or circle given three points on its circumference.

Parameters
aStartThe starting point of the circle (equivalent to aEnd)
aMidThe point on the arc, half-way between aStart and aEnd
aEndThe ending point of the circle (equivalent to aStart)
Returns
The center of the circle

Definition at line 397 of file trigo.cpp.

398 {
399  VECTOR2D dStart( static_cast<double>( aStart.x ), static_cast<double>( aStart.y ) );
400  VECTOR2D dMid( static_cast<double>( aMid.x ), static_cast<double>( aMid.y ) );
401  VECTOR2D dEnd( static_cast<double>( aEnd.x ), static_cast<double>( aEnd.y ) );
402  VECTOR2D dCenter = GetArcCenter( dStart, dMid, dEnd );
403 
404  VECTOR2I iCenter;
405 
406  iCenter.x = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
407  dCenter.x,
408  double( std::numeric_limits<int>::max() / 2.0 ) ) );
409 
410  iCenter.y = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
411  dCenter.y,
412  double( std::numeric_limits<int>::max() / 2.0 ) ) );
413 
414  return iCenter;
415 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
const VECTOR2D GetArcCenter(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd)
Definition: trigo.cpp:341
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61

References GetArcCenter(), KiROUND(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by ARC::GetPosition(), ARC::GetRadius(), SCH_SEXPR_PARSER::parseArc(), and POINT_EDITOR::updateItem().

◆ GetArcCenter() [2/3]

const VECTOR2D GetArcCenter ( const VECTOR2D aStart,
const VECTOR2D aMid,
const VECTOR2D aEnd 
)

Definition at line 341 of file trigo.cpp.

342 {
343  VECTOR2D center;
344  double yDelta_21 = aMid.y - aStart.y;
345  double xDelta_21 = aMid.x - aStart.x;
346  double yDelta_32 = aEnd.y - aMid.y;
347  double xDelta_32 = aEnd.x - aMid.x;
348 
349  // This is a special case for aMid as the half-way point when aSlope = 0 and bSlope = inf
350  // or the other way around. In that case, the center lies in a straight line between
351  // aStart and aEnd
352  if( ( ( xDelta_21 == 0.0 ) && ( yDelta_32 == 0.0 ) ) ||
353  ( ( yDelta_21 == 0.0 ) && ( xDelta_32 == 0.0 ) ) )
354  {
355  center.x = ( aStart.x + aEnd.x ) / 2.0;
356  center.y = ( aStart.y + aEnd.y ) / 2.0 ;
357  return center;
358  }
359 
360  // Prevent div=0 errors
361  if( xDelta_21 == 0.0 )
362  xDelta_21 = std::numeric_limits<double>::epsilon();
363 
364  if( xDelta_32 == 0.0 )
365  xDelta_32 = -std::numeric_limits<double>::epsilon();
366 
367  double aSlope = yDelta_21 / xDelta_21;
368  double bSlope = yDelta_32 / xDelta_32;
369 
370  // If the points are colinear, the center is at infinity, so offset
371  // the slope by a minimal amount
372  // Warning: This will induce a small error in the center location
373  if( yDelta_32 * xDelta_21 == yDelta_21 * xDelta_32 )
374  {
375  aSlope += std::numeric_limits<double>::epsilon();
376  bSlope -= std::numeric_limits<double>::epsilon();
377  }
378 
379  if( aSlope == 0.0 )
380  aSlope = std::numeric_limits<double>::epsilon();
381 
382  if( bSlope == 0.0 )
383  bSlope = -std::numeric_limits<double>::epsilon();
384 
385 
386  center.x = ( aSlope * bSlope * ( aStart.y - aEnd.y ) +
387  bSlope * ( aStart.x + aMid.x ) -
388  aSlope * ( aMid.x + aEnd.x ) ) / ( 2 * ( bSlope - aSlope ) );
389 
390  center.y = ( ( ( aStart.x + aMid.x ) / 2.0 - center.x ) / aSlope +
391  ( aStart.y + aMid.y ) / 2.0 );
392 
393  return center;
394 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by GetArcCenter().

◆ GetArcCenter() [3/3]

const wxPoint GetArcCenter ( const wxPoint aStart,
const wxPoint aMid,
const wxPoint aEnd 
)

Definition at line 418 of file trigo.cpp.

419 {
420  VECTOR2D dStart( static_cast<double>( aStart.x ), static_cast<double>( aStart.y ) );
421  VECTOR2D dMid( static_cast<double>( aMid.x ), static_cast<double>( aMid.y ) );
422  VECTOR2D dEnd( static_cast<double>( aEnd.x ), static_cast<double>( aEnd.y ) );
423  VECTOR2D dCenter = GetArcCenter( dStart, dMid, dEnd );
424 
425  wxPoint iCenter;
426 
427  iCenter.x = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
428  dCenter.x,
429  double( std::numeric_limits<int>::max() / 2.0 ) ) );
430 
431  iCenter.y = KiROUND( Clamp<double>( double( std::numeric_limits<int>::min() / 2.0 ),
432  dCenter.y,
433  double( std::numeric_limits<int>::max() / 2.0 ) ) );
434 
435  return iCenter;
436 }
VECTOR2 defines a general 2D-vector/point.
Definition: vector2d.h:61
const VECTOR2D GetArcCenter(const VECTOR2D &aStart, const VECTOR2D &aMid, const VECTOR2D &aEnd)
Definition: trigo.cpp:341
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61

References GetArcCenter(), KiROUND(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

◆ GetLineLength()

double GetLineLength ( const wxPoint aPointA,
const wxPoint aPointB 
)
inline

◆ HitTestPoints()

bool HitTestPoints ( const wxPoint pointA,
const wxPoint pointB,
double  threshold 
)
inline

Test, if two points are near each other.

Parameters
pointAFirst point
pointBSecond point
thresholdThe maximum distance
Returns
True or false

Definition at line 166 of file trigo.h.

168 {
169  wxPoint vectorAB = pointB - pointA;
170 
171  // Compare the distances squared. The double is needed to avoid
172  // overflow during int multiplication
173  double sqdistance = (double)vectorAB.x * vectorAB.x +
174  (double)vectorAB.y * vectorAB.y;
175 
176  return sqdistance < threshold * threshold;
177 }

References wxPoint::x, and wxPoint::y.

Referenced by LIB_ARC::HitTest(), GERBER_DRAW_ITEM::HitTest(), and EE_SELECTION_TOOL::SelectPoint().

◆ InterceptsNegativeX()

bool InterceptsNegativeX ( double  aStartAngle,
double  aEndAngle 
)
inline

Test if an arc from aStartAngle to aEndAngle crosses the negative X axis (180 degrees).

Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).

Parameters
aStartAngleThe arc start angle in degrees.
aEndAngleThe arc end angle in degrees.

Definition at line 385 of file trigo.h.

386 {
387  double end = aEndAngle;
388 
389  if( aStartAngle > aEndAngle )
390  end += 360.0;
391 
392  return aStartAngle < 180.0 && end > 180.0;
393 }

Referenced by BOOST_AUTO_TEST_CASE().

◆ InterceptsPositiveX()

bool InterceptsPositiveX ( double  aStartAngle,
double  aEndAngle 
)
inline

Test if an arc from aStartAngle to aEndAngle crosses the positive X axis (0 degrees).

Testing is performed in the quadrant 1 to quadrant 4 direction (counter-clockwise).

Parameters
aStartAngleThe arc start angle in degrees.
aEndAngleThe arc end angle in degrees.

Definition at line 367 of file trigo.h.

368 {
369  double end = aEndAngle;
370 
371  if( aStartAngle > aEndAngle )
372  end += 360.0;
373 
374  return aStartAngle < 360.0 && end > 360.0;
375 }

Referenced by BOOST_AUTO_TEST_CASE().

◆ IsPointOnSegment()

bool IsPointOnSegment ( const wxPoint aSegStart,
const wxPoint aSegEnd,
const wxPoint aTestPoint 
)

Test if aTestPoint is on line defined by aSegStart and aSegEnd.

This function is faster than TestSegmentHit() because aTestPoint should be exactly on the line. This works fine only for H, V and 45 degree line segments.

Parameters
aSegStartThe first point of the line segment.
aSegEndThe second point of the line segment.
aTestPointThe point to test.
Returns
true if the point is on the line segment.

Definition at line 42 of file trigo.cpp.

44 {
45  wxPoint vectSeg = aSegEnd - aSegStart; // Vector from S1 to S2
46  wxPoint vectPoint = aTestPoint - aSegStart; // Vector from S1 to P
47 
48  // Use long long here to avoid overflow in calculations
49  if( (long long) vectSeg.x * vectPoint.y - (long long) vectSeg.y * vectPoint.x )
50  return false; /* Cross product non-zero, vectors not parallel */
51 
52  if( ( (long long) vectSeg.x * vectPoint.x + (long long) vectSeg.y * vectPoint.y ) <
53  ( (long long) vectPoint.x * vectPoint.x + (long long) vectPoint.y * vectPoint.y ) )
54  return false; /* Point not on segment */
55 
56  return true;
57 }

References wxPoint::x, and wxPoint::y.

Referenced by SCH_LINE_WIRE_BUS_TOOL::AddJunctionsIfNeeded(), SCH_EDIT_FRAME::BreakSegment(), SCH_LINE_WIRE_BUS_TOOL::finishSegments(), NETLIST_OBJECT_LIST::segmentToPointConnect(), SCH_EDIT_FRAME::TrimWire(), SCH_BUS_WIRE_ENTRY::UpdateDanglingState(), SCH_BUS_BUS_ENTRY::UpdateDanglingState(), and SCH_TEXT::UpdateDanglingState().

◆ NEGATE_AND_NORMALIZE_ANGLE_POS()

template<class T >
void NEGATE_AND_NORMALIZE_ANGLE_POS ( T &  Angle)
inline

Definition at line 322 of file trigo.h.

323 {
324  Angle = NegateAndNormalizeAnglePos( Angle );
325 }
T NegateAndNormalizeAnglePos(T Angle)
Definition: trigo.h:312

References NegateAndNormalizeAnglePos().

Referenced by CreateComponentsSection().

◆ NegateAndNormalizeAnglePos()

template<class T >
T NegateAndNormalizeAnglePos ( Angle)
inline

Definition at line 312 of file trigo.h.

313 {
314  Angle = -Angle;
315  while( Angle < 0 )
316  Angle += 3600;
317  while( Angle >= 3600 )
318  Angle -= 3600;
319  return Angle;
320 }

Referenced by NEGATE_AND_NORMALIZE_ANGLE_POS().

◆ NORMALIZE_ANGLE_180()

template<class T >
void NORMALIZE_ANGLE_180 ( T &  Angle)
inline

Definition at line 354 of file trigo.h.

355 {
356  Angle = NormalizeAngle180( Angle );
357 }
T NormalizeAngle180(T Angle)
Normalize angle to be in the -180.0 .. 180.0 range.
Definition: trigo.h:345

References NormalizeAngle180().

Referenced by HPGL_PLOTTER::Arc(), MODULE::Flip(), DIALOG_PAD_PROPERTIES::initValues(), and MODULE::SetOrientation().

◆ NORMALIZE_ANGLE_90()

template<class T >
void NORMALIZE_ANGLE_90 ( T &  Angle)
inline

Definition at line 338 of file trigo.h.

339 {
340  Angle = NormalizeAngle90( Angle );
341 }
T NormalizeAngle90(T Angle)
Normalize angle to be in the -90.0 .. 90.0 range.
Definition: trigo.h:329

References NormalizeAngle90().

Referenced by KIGFX::PCB_PAINTER::draw(), GERBER_DRAW_ITEM::GetTextD_CodePrms(), and D_PAD::PrintShape().

◆ NORMALIZE_ANGLE_DEGREES_POS()

void NORMALIZE_ANGLE_DEGREES_POS ( double &  Angle)
inline

Definition at line 275 of file trigo.h.

276 {
277  Angle = NormalizeAngleDegreesPos( Angle );
278 }
double NormalizeAngleDegreesPos(double Angle)
Normalize angle to be in the 0.0 .
Definition: trigo.h:265

References NormalizeAngleDegreesPos().

Referenced by DSN::SPECCTRA_DB::FromBOARD(), and DSN::SPECCTRA_DB::makeIMAGE().

◆ NORMALIZE_ANGLE_POS()

◆ NormalizeAngle180()

template<class T >
T NormalizeAngle180 ( Angle)
inline

Normalize angle to be in the -180.0 .. 180.0 range.

Definition at line 345 of file trigo.h.

346 {
347  while( Angle <= -1800 )
348  Angle += 3600;
349  while( Angle > 1800 )
350  Angle -= 3600;
351  return Angle;
352 }

Referenced by DIALOG_COPPER_ZONE::AcceptOptions(), ARC::GetAngle(), and NORMALIZE_ANGLE_180().

◆ NormalizeAngle360Max()

template<class T >
T NormalizeAngle360Max ( Angle)
inline

Normalize angle to be >=-360.0 and <= 360.0 Angle can be equal to -360 or +360.

Definition at line 226 of file trigo.h.

227 {
228  while( Angle < -3600 )
229  Angle += 3600;
230  while( Angle > 3600 )
231  Angle -= 3600;
232  return Angle;
233 }

Referenced by DRAWSEGMENT::SetAngle().

◆ NormalizeAngle360Min()

template<class T >
T NormalizeAngle360Min ( Angle)
inline

Normalize angle to be > -360.0 and < 360.0 Angle equal to -360 or +360 are set to 0.

Definition at line 237 of file trigo.h.

238 {
239  while( Angle <= -3600 )
240  Angle += 3600;
241  while( Angle >= 3600 )
242  Angle -= 3600;
243  return Angle;
244 }

Referenced by PCB_IO::format(), D_PAD::Rotate(), TEXTE_PCB::SetTextAngle(), TEXTE_MODULE::SetTextAngle(), and WS_DRAW_ITEM_TEXT::SetTextAngle().

◆ NormalizeAngle90()

template<class T >
T NormalizeAngle90 ( Angle)
inline

Normalize angle to be in the -90.0 .. 90.0 range.

Definition at line 329 of file trigo.h.

330 {
331  while( Angle < -900 )
332  Angle += 1800;
333  while( Angle > 900 )
334  Angle -= 1800;
335  return Angle;
336 }

Referenced by NORMALIZE_ANGLE_90().

◆ NormalizeAngleDegrees()

double NormalizeAngleDegrees ( double  Angle,
double  aMin,
double  aMax 
)
inline

Normalize angle to be aMin < angle <= aMax angle is in degrees.

Definition at line 292 of file trigo.h.

293 {
294  while( Angle < aMin )
295  Angle += 360.0;
296  while( Angle >= aMax )
297  Angle -= 360.0;
298  return Angle;
299 }

◆ NormalizeAngleDegreesPos()

double NormalizeAngleDegreesPos ( double  Angle)
inline

Normalize angle to be in the 0.0 .

. 360.0 range: angle is in degrees

Definition at line 265 of file trigo.h.

266 {
267  while( Angle < 0 )
268  Angle += 360.0;
269  while( Angle >= 360.0 )
270  Angle -= 360.0;
271  return Angle;
272 }

Referenced by NORMALIZE_ANGLE_DEGREES_POS().

◆ NormalizeAnglePos()

template<class T >
T NormalizeAnglePos ( Angle)
inline

Normalize angle to be in the 0.0 .

. 360.0 range: angle is in 1/10 degrees

Definition at line 248 of file trigo.h.

249 {
250  while( Angle < 0 )
251  Angle += 3600;
252  while( Angle >= 3600 )
253  Angle -= 3600;
254  return Angle;
255 }

Referenced by PCB_IO::format(), ARC::GetArcAngleEnd(), ARC::GetArcAngleStart(), TEXT_MOD_GRID_TABLE::GetValue(), and NORMALIZE_ANGLE_POS().

◆ NormalizeAngleRadiansPos()

double NormalizeAngleRadiansPos ( double  Angle)
inline

Definition at line 281 of file trigo.h.

282 {
283  while( Angle < 0 )
284  Angle += (2 * M_PI );
285  while( Angle >= ( 2 * M_PI ) )
286  Angle -= ( 2 * M_PI );
287  return Angle;
288 }

Referenced by GERBER_DRAW_ITEM::HitTest().

◆ RAD2DECIDEG()

◆ RAD2DEG()

◆ RotatePoint() [1/8]

void RotatePoint ( int *  pX,
int *  pY,
double  angle 
)

Definition at line 208 of file trigo.cpp.

209 {
210  int tmp;
211 
213 
214  // Cheap and dirty optimizations for 0, 90, 180, and 270 degrees.
215  if( angle == 0 )
216  return;
217 
218  if( angle == 900 ) /* sin = 1, cos = 0 */
219  {
220  tmp = *pX;
221  *pX = *pY;
222  *pY = -tmp;
223  }
224  else if( angle == 1800 ) /* sin = 0, cos = -1 */
225  {
226  *pX = -*pX;
227  *pY = -*pY;
228  }
229  else if( angle == 2700 ) /* sin = -1, cos = 0 */
230  {
231  tmp = *pX;
232  *pX = -*pY;
233  *pY = tmp;
234  }
235  else
236  {
237  double fangle = DECIDEG2RAD( angle );
238  double sinus = sin( fangle );
239  double cosinus = cos( fangle );
240  double fpx = (*pY * sinus ) + (*pX * cosinus );
241  double fpy = (*pY * cosinus ) - (*pX * sinus );
242  *pX = KiROUND( fpx );
243  *pY = KiROUND( fpy );
244  }
245 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double DECIDEG2RAD(double deg)
Definition: trigo.h:218
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61

References PNS::angle(), DECIDEG2RAD(), KiROUND(), and NORMALIZE_ANGLE_POS().

Referenced by PCAD2KICAD::PCB_MODULE::AddToBoard(), PCAD2KICAD::PCB_PAD::AddToModule(), SVG_PLOTTER::Arc(), BuildConvexHull(), BuildCornersList_S_Shape(), D_PAD::BuildPadPolygon(), D_PAD::BuildSegmentFromOvalShape(), LIB_ARC::CalcEdit(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), DRAWSEGMENT::computeArcBBox(), PSLIKE_PLOTTER::computeTextParameters(), convertOblong2Segment(), ConvertOutlineToPolygon(), AM_PRIMITIVE::ConvertShapeToPolygon(), D_CODE::ConvertShapeToPolygon(), PCAD2KICAD::CorrectTextPosition(), PCB_EDIT_FRAME::Create_MuWaveComponent(), EXCELLON_WRITER::createDrillFile(), SCH_GLOBALLABEL::CreateGraphicShape(), CINFO3D_VISU::createNewPadWithClearance(), DRC::doTrackDrc(), AM_PRIMITIVE::DrawBasicShape(), AR_MATRIX::drawSegmentQcq(), GBR_TO_PCB_EXPORTER::export_segarc_copper_item(), export_vrml_module(), export_vrml_padshape(), fillArcPOLY(), HPGL_PLOTTER::FlashPadOval(), PSLIKE_PLOTTER::FlashPadOval(), GERBER_PLOTTER::FlashPadOval(), HPGL_PLOTTER::FlashPadRect(), PSLIKE_PLOTTER::FlashPadRect(), DXF_PLOTTER::FlashPadRect(), HPGL_PLOTTER::FlashPadTrapez(), PSLIKE_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashPadTrapez(), DXF_PLOTTER::FlashPadTrapez(), GERBER_PLOTTER::FlashRegularPolygon(), FootprintWriteShape(), geom_transf(), GERBER_DRAW_ITEM::GetABPosition(), CN_ITEM::GetAnchor(), DRAWSEGMENT::GetArcEnd(), DRAWSEGMENT::GetArcMid(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), LIB_PIN::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), DRAWSEGMENT::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), D_PAD::GetBoundingBox(), EDA_RECT::GetBoundingBoxRotated(), WS_DATA_ITEM_POLYGONS::GetCornerPosition(), D_PAD::GetOblongDrillGeometry(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), GetRoundRectCornerCenters(), ARRAY_CIRCULAR_OPTIONS::GetTransform(), GERBER_DRAW_ITEM::GetXYPosition(), GRArc(), GRCSegm(), GRFilledArc(), D_PAD::HitTest(), idf_export_module(), C3D_RENDER_RAYTRACING::insert3DPadHole(), EDA_RECT::Intersects(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), LEGACY_PLUGIN::loadPAD(), MODULE::MoveAnchorPosition(), OGL_draw_half_open_cylinder(), GPCB_FPL_CACHE::parseMODULE(), PCB_PARSER::parseMODULE_unchecked(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), EDGE_MODULE::Print(), VIA::Print(), D_PAD::PrintShape(), SCH_JUNCTION::Rotate(), TEXTE_PCB::Rotate(), SCH_MARKER::Rotate(), LIB_RECTANGLE::Rotate(), PCB_TARGET::Rotate(), LIB_CIRCLE::Rotate(), LIB_BEZIER::Rotate(), SCH_NO_CONNECT::Rotate(), LIB_TEXT::Rotate(), SCH_BUS_ENTRY_BASE::Rotate(), LIB_ARC::Rotate(), TRACK::Rotate(), LIB_POLYLINE::Rotate(), MARKER_PCB::Rotate(), TEXTE_MODULE::Rotate(), PAD_CS_PRIMITIVE::Rotate(), SCH_BITMAP::Rotate(), SCH_FIELD::Rotate(), SCH_LINE::Rotate(), SCH_SHEET_PIN::Rotate(), LIB_FIELD::Rotate(), DIMENSION::Rotate(), DRAWSEGMENT::Rotate(), MODULE::Rotate(), SCH_TEXT::Rotate(), ARC::Rotate(), ZONE_CONTAINER::Rotate(), LIB_PIN::Rotate(), SCH_SHEET::Rotate(), SCH_COMPONENT::Rotate(), D_PAD::Rotate(), SCH_LINE::RotateEnd(), RotatePoint(), SCH_LINE::RotateStart(), WS_DATA_ITEM_POLYGONS::SetBoundingBox(), EDGE_MODULE::SetDrawCoord(), TEXTE_MODULE::SetDrawCoord(), D_PAD::SetDrawCoord(), EDGE_MODULE::SetLocalCoord(), TEXTE_MODULE::SetLocalCoord(), D_PAD::SetLocalCoord(), D_PAD::ShapePos(), PLOTTER::sketchOval(), PNS_KICAD_IFACE_BASE::syncPad(), TEXTE_MODULE::TextHitTest(), EDA_TEXT::TextHitTest(), AR_MATRIX::TraceFilledRectangle(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), EAGLE_PLUGIN::transferPad(), TransformArcToPolygon(), CINFO3D_VISU::TransformArcToSegments(), EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon(), TransformCircleToPolygon(), TransformOvalToPolygon(), TransformSegmentToPolygon(), DRAWSEGMENT::TransformShapeWithClearanceToPolygon(), and D_PAD::TransformShapeWithClearanceToPolygon().

◆ RotatePoint() [2/8]

void RotatePoint ( int *  pX,
int *  pY,
int  cx,
int  cy,
double  angle 
)

Definition at line 248 of file trigo.cpp.

249 {
250  int ox, oy;
251 
252  ox = *pX - cx;
253  oy = *pY - cy;
254 
255  RotatePoint( &ox, &oy, angle );
256 
257  *pX = ox + cx;
258  *pY = oy + cy;
259 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), and RotatePoint().

◆ RotatePoint() [3/8]

void RotatePoint ( wxPoint point,
double  angle 
)
inline

Definition at line 81 of file trigo.h.

82 {
83  RotatePoint( &point->x, &point->y, angle );
84 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), RotatePoint(), wxPoint::x, and wxPoint::y.

◆ RotatePoint() [4/8]

void RotatePoint ( VECTOR2I point,
double  angle 
)
inline

Definition at line 86 of file trigo.h.

87 {
88  RotatePoint( &point.x, &point.y, angle );
89 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), RotatePoint(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ RotatePoint() [5/8]

void RotatePoint ( VECTOR2I point,
const VECTOR2I centre,
double  angle 
)

Definition at line 274 of file trigo.cpp.

275 {
276  wxPoint c( centre.x, centre.y );
277  wxPoint p( point.x, point.y );
278 
279  RotatePoint(&p, c, angle);
280 
281  point.x = p.x;
282  point.y = p.y;
283 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), RotatePoint(), wxPoint::x, VECTOR2< T >::x, wxPoint::y, and VECTOR2< T >::y.

◆ RotatePoint() [6/8]

void RotatePoint ( wxPoint point,
const wxPoint centre,
double  angle 
)

Definition at line 262 of file trigo.cpp.

263 {
264  int ox, oy;
265 
266  ox = point->x - centre.x;
267  oy = point->y - centre.y;
268 
269  RotatePoint( &ox, &oy, angle );
270  point->x = ox + centre.x;
271  point->y = oy + centre.y;
272 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), RotatePoint(), wxPoint::x, and wxPoint::y.

◆ RotatePoint() [7/8]

void RotatePoint ( double *  pX,
double *  pY,
double  angle 
)

Definition at line 300 of file trigo.cpp.

301 {
302  double tmp;
303 
305 
306  // Cheap and dirty optimizations for 0, 90, 180, and 270 degrees.
307  if( angle == 0 )
308  return;
309 
310  if( angle == 900 ) /* sin = 1, cos = 0 */
311  {
312  tmp = *pX;
313  *pX = *pY;
314  *pY = -tmp;
315  }
316  else if( angle == 1800 ) /* sin = 0, cos = -1 */
317  {
318  *pX = -*pX;
319  *pY = -*pY;
320  }
321  else if( angle == 2700 ) /* sin = -1, cos = 0 */
322  {
323  tmp = *pX;
324  *pX = -*pY;
325  *pY = tmp;
326  }
327  else
328  {
329  double fangle = DECIDEG2RAD( angle );
330  double sinus = sin( fangle );
331  double cosinus = cos( fangle );
332 
333  double fpx = (*pY * sinus ) + (*pX * cosinus );
334  double fpy = (*pY * cosinus ) - (*pX * sinus );
335  *pX = fpx;
336  *pY = fpy;
337  }
338 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:257
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double DECIDEG2RAD(double deg)
Definition: trigo.h:218

References PNS::angle(), DECIDEG2RAD(), and NORMALIZE_ANGLE_POS().

◆ RotatePoint() [8/8]

void RotatePoint ( double *  pX,
double *  pY,
double  cx,
double  cy,
double  angle 
)

Definition at line 286 of file trigo.cpp.

287 {
288  double ox, oy;
289 
290  ox = *pX - cx;
291  oy = *pY - cy;
292 
293  RotatePoint( &ox, &oy, angle );
294 
295  *pX = ox + cx;
296  *pY = oy + cy;
297 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:208
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References PNS::angle(), and RotatePoint().

◆ SegmentIntersectsSegment()

bool SegmentIntersectsSegment ( const wxPoint a_p1_l1,
const wxPoint a_p2_l1,
const wxPoint a_p1_l2,
const wxPoint a_p2_l2,
wxPoint aIntersectionPoint = nullptr 
)

Test if two lines intersect.

Parameters
a_p1_l1The first point of the first line.
a_p2_l1The second point of the first line.
a_p1_l2The first point of the second line.
a_p2_l2The second point of the second line.
aIntersectionPointis filled with the intersection point if it exists
Returns
bool - true if the two segments defined by four points intersect. (i.e. if the 2 segments have at least a common point)

Definition at line 61 of file trigo.cpp.

64 {
65 
66  //We are forced to use 64bit ints because the internal units can overflow 32bit ints when
67  // multiplied with each other, the alternative would be to scale the units down (i.e. divide
68  // by a fixed number).
69  long long dX_a, dY_a, dX_b, dY_b, dX_ab, dY_ab;
70  long long num_a, num_b, den;
71 
72  //Test for intersection within the bounds of both line segments using line equations of the
73  // form:
74  // x_k(u_k) = u_k * dX_k + x_k(0)
75  // y_k(u_k) = u_k * dY_k + y_k(0)
76  // with 0 <= u_k <= 1 and k = [ a, b ]
77 
78  dX_a = a_p2_l1.x - a_p1_l1.x;
79  dY_a = a_p2_l1.y - a_p1_l1.y;
80  dX_b = a_p2_l2.x - a_p1_l2.x;
81  dY_b = a_p2_l2.y - a_p1_l2.y;
82  dX_ab = a_p1_l2.x - a_p1_l1.x;
83  dY_ab = a_p1_l2.y - a_p1_l1.y;
84 
85  den = dY_a * dX_b - dY_b * dX_a ;
86 
87  //Check if lines are parallel
88  if( den == 0 )
89  return false;
90 
91  num_a = dY_ab * dX_b - dY_b * dX_ab;
92  num_b = dY_ab * dX_a - dY_a * dX_ab;
93 
94  // Only compute the intersection point if requested
95  if( aIntersectionPoint )
96  {
97  *aIntersectionPoint = a_p1_l1;
98  aIntersectionPoint->x += KiROUND( dX_a * ( double )num_a / ( double )den );
99  aIntersectionPoint->y += KiROUND( dY_a * ( double )num_b / ( double )den );
100  }
101 
102  if( den < 0 )
103  {
104  den = -den;
105  num_a = -num_a;
106  num_b = -num_b;
107  }
108 
109  //Test sign( u_a ) and return false if negative
110  if( num_a < 0 )
111  return false;
112 
113  //Test sign( u_b ) and return false if negative
114  if( num_b < 0 )
115  return false;
116 
117  //Test to ensure (u_a <= 1)
118  if( num_a > den )
119  return false;
120 
121  //Test to ensure (u_b <= 1)
122  if( num_b > den )
123  return false;
124 
125  return true;
126 }
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:61

References KiROUND(), wxPoint::x, and wxPoint::y.

Referenced by DRC::doTrackDrc(), and EDA_RECT::Intersects().

◆ sindecideg()

double sindecideg ( double  r,
double  a 
)
inline

Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.

Definition at line 399 of file trigo.h.

400 {
401  return r * sin( DECIDEG2RAD( a ) );
402 }
double DECIDEG2RAD(double deg)
Definition: trigo.h:218

References DECIDEG2RAD().

Referenced by PLOTTER::Arc(), HPGL_PLOTTER::Arc(), PDF_PLOTTER::Arc(), GERBER_PLOTTER::Arc(), PCAD2KICAD::PCB_ARC::Parse(), and AR_MATRIX::traceCircle().

◆ TestSegmentHit()

bool TestSegmentHit ( const wxPoint aRefPoint,
wxPoint  aStart,
wxPoint  aEnd,
int  aDist 
)

Test if aRefPoint is with aDistance on the line defined by aStart and aEnd.

Parameters
aRefPoint= reference point to test
aStartis the first end-point of the line segment
aEndis the second end-point of the line segment
aDist= maximum distance for hit

Definition at line 129 of file trigo.cpp.

130 {
131  int xmin = aStart.x;
132  int xmax = aEnd.x;
133  int ymin = aStart.y;
134  int ymax = aEnd.y;
135  wxPoint delta = aStart - aRefPoint;
136 
137  if( xmax < xmin )
138  std::swap( xmax, xmin );
139 
140  if( ymax < ymin )
141  std::swap( ymax, ymin );
142 
143  // First, check if we are outside of the bounding box
144  if( ( ymin - aRefPoint.y > aDist ) || ( aRefPoint.y - ymax > aDist ) )
145  return false;
146 
147  if( ( xmin - aRefPoint.x > aDist ) || ( aRefPoint.x - xmax > aDist ) )
148  return false;
149 
150  // Next, eliminate easy cases
151  if( aStart.x == aEnd.x && aRefPoint.y > ymin && aRefPoint.y < ymax )
152  return std::abs( delta.x ) <= aDist;
153 
154  if( aStart.y == aEnd.y && aRefPoint.x > xmin && aRefPoint.x < xmax )
155  return std::abs( delta.y ) <= aDist;
156 
157  SEG segment( aStart, aEnd );
158  return segment.PointCloserThan( aRefPoint, aDist + 1 );
159 }
Definition: seg.h:39

References SEG::PointCloserThan(), wxPoint::x, and wxPoint::y.

Referenced by SCH_EAGLE_PLUGIN::addBusEntries(), DRAWING_TOOL::DrawVia(), LIB_RECTANGLE::HitTest(), LIB_BEZIER::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), WS_DRAW_ITEM_LINE::HitTest(), TRACK::HitTest(), SCH_LINE::HitTest(), WS_DRAW_ITEM_RECT::HitTest(), DRAWSEGMENT::HitTest(), DIMENSION::HitTest(), GERBER_DRAW_ITEM::HitTest(), D_PAD::HitTest(), and SCH_EAGLE_PLUGIN::moveLabels().