KiCad PCB EDA Suite
trigo.cpp File Reference

Trigonometric and geometric basic functions. More...

#include <fctsys.h>
#include <macros.h>
#include <trigo.h>
#include <common.h>
#include <math_for_graphics.h>

Go to the source code of this file.

Functions

bool IsPointOnSegment (const wxPoint &aSegStart, const wxPoint &aSegEnd, const wxPoint &aTestPoint)
 Function IsPointOnSegment. More...
 
bool SegmentIntersectsSegment (const wxPoint &a_p1_l1, const wxPoint &a_p2_l1, const wxPoint &a_p1_l2, const wxPoint &a_p2_l2)
 Function SegmentIntersectsSegment. More...
 
static double square (int x)
 
bool TestSegmentHit (const wxPoint &aRefPoint, wxPoint aStart, wxPoint aEnd, int aDist)
 Function TestSegmentHit test for hit on line segment i.e. More...
 
double ArcTangente (int dy, int dx)
 
void RotatePoint (int *pX, int *pY, double angle)
 
void RotatePoint (int *pX, int *pY, int cx, int cy, double angle)
 
void RotatePoint (wxPoint *point, const wxPoint &centre, double angle)
 
void RotatePoint (double *pX, double *pY, double cx, double cy, double angle)
 
void RotatePoint (double *pX, double *pY, double angle)
 

Detailed Description

Trigonometric and geometric basic functions.

Definition in file trigo.cpp.

Function Documentation

double ArcTangente ( int  dy,
int  dx 
)

Definition at line 271 of file trigo.cpp.

References RAD2DECIDEG().

Referenced by BuildCornersList_S_Shape(), LIB_ARC::calcEdit(), LIB_ARC::calcRadiusAngles(), DRC::checkClearancePadToPad(), AM_PRIMITIVE::ConvertShapeToPolygon(), DRC::doTrackDrc(), EDGE_MODULE::Draw(), DRAWSEGMENT::Draw(), DrawSegmentQcq(), fillArcPOLY(), DRAWSEGMENT::GetArcAngleStart(), GRCSegm(), DRAWSEGMENT::HitTest(), PCAD2KICAD::PCB_ARC::Parse(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), BRDITEMS_PLOTTER::PlotDrawSegment(), PLOTTER::segmentAsOval(), ShowBoundingBoxMicroWaveInductor(), DRC::testTexts(), TraceArc(), TransformRoundedEndsSegmentToPolygon(), and PCB_BASE_FRAME::UpdateStatusBar().

272 {
273 
274  /* gcc is surprisingly smart in optimizing these conditions in
275  a tree! */
276 
277  if( dx == 0 && dy == 0 )
278  return 0;
279 
280  if( dy == 0 )
281  {
282  if( dx >= 0 )
283  return 0;
284  else
285  return -1800;
286  }
287 
288  if( dx == 0 )
289  {
290  if( dy >= 0 )
291  return 900;
292  else
293  return -900;
294  }
295 
296  if( dx == dy )
297  {
298  if( dx >= 0 )
299  return 450;
300  else
301  return -1800 + 450;
302  }
303 
304  if( dx == -dy )
305  {
306  if( dx >= 0 )
307  return -450;
308  else
309  return 1800 - 450;
310  }
311 
312  // Of course dy and dx are treated as double
313  return RAD2DECIDEG( atan2( (double) dy, (double) dx ) );
314 }
double RAD2DECIDEG(double rad)
Definition: trigo.h:196
bool IsPointOnSegment ( const wxPoint aSegStart,
const wxPoint aSegEnd,
const wxPoint aTestPoint 
)

Function IsPointOnSegment.

Parameters
aSegStartThe first point of the segment S.
aSegEndThe second point of the segment S.
aTestPointThe point P to test.
Returns
true if the point P is on the segment S. faster than TestSegmentHit() because P should be exactly on S therefore works fine only for H, V and 45 deg segm. suitable for busses and wires in eeschema, otherwise use TestSegmentHit()

Definition at line 39 of file trigo.cpp.

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

Referenced by SCH_BUS_ENTRY_BASE::IsDanglingStateChanged(), SCH_TEXT::IsDanglingStateChanged(), RemoveBacktracks(), and NETLIST_OBJECT_LIST::segmentToPointConnect().

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

Definition at line 317 of file trigo.cpp.

References DECIDEG2RAD(), KiROUND(), and NORMALIZE_ANGLE_POS().

Referenced by DXF2BRD_CONVERTER::addArc(), addHoleToPolygon(), PCB_BASE_FRAME::AddPad(), CINFO3D_VISU::AddShapeWithClearanceToContainer(), PCAD2KICAD::PCB_MODULE::AddToBoard(), PCAD2KICAD::PCB_PAD::AddToModule(), SVG_PLOTTER::Arc(), FOOTPRINT_EDIT_FRAME::Begin_Edge_Module(), BuildConvexHull(), BuildCornersList_S_Shape(), D_PAD::BuildPadPolygon(), D_PAD::BuildSegmentFromOvalShape(), BuildUnconnectedThermalStubsPolygonList(), LIB_ARC::calcEdit(), DRC::checkClearancePadToPad(), DRC::checkClearanceSegmToPad(), DRAWSEGMENT::computeArcBBox(), PSLIKE_PLOTTER::computeTextParameters(), convertOblong2Segment(), ConvertOutlineToPolygon(), AM_PRIMITIVE::ConvertShapeToPolygon(), D_CODE::ConvertShapeToPolygon(), PCB_EDIT_FRAME::Create_MuWaveComponent(), EXCELLON_WRITER::createDrillFile(), SCH_GLOBALLABEL::CreateGraphicShape(), CINFO3D_VISU::createNewPadWithClearance(), CreateThermalReliefPadPolygon(), DRC::doTrackDrc(), EDGE_MODULE::Draw(), VIA::Draw(), AM_PRIMITIVE::DrawBasicShape(), DrawSegmentQcq(), D_PAD::DrawShape(), PCB_EDIT_FRAME::Edit_Gap(), GBR_TO_PCB_EXPORTER::export_segarc_copper_item(), export_vrml_edge_module(), 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(), FootprintWriteShape(), GERBER_DRAW_ITEM::GetABPosition(), DRAWSEGMENT::GetArcEnd(), LIB_TEXT::GetBoundingBox(), SCH_FIELD::GetBoundingBox(), LIB_PIN::GetBoundingBox(), SCH_TEXT::GetBoundingBox(), LIB_FIELD::GetBoundingBox(), DRAWSEGMENT::GetBoundingBox(), SCH_LABEL::GetBoundingBox(), D_PAD::GetBoundingBox(), EDA_RECT::GetBoundingBoxRotated(), WORKSHEET_DATAITEM_POLYPOLYGON::GetCornerPosition(), D_PAD::GetOblongDrillGeometry(), EDA_TEXT::GetPositionsOfLinesOfMultilineText(), GetRoundRectCornerCenters(), GERBER_DRAW_ITEM::GetXYPosition(), GRArc(), GRCSegm(), GRFilledArc(), D_PAD::HitTest(), idf_export_module(), InitialiseDragParameters(), C3D_RENDER_RAYTRACING::insert3DPadHole(), EDA_RECT::Intersects(), LIB_ARC::Load(), SCH_LEGACY_PLUGIN_CACHE::loadArc(), LEGACY_PLUGIN::loadPAD(), MODULE::MoveAnchorPosition(), MoveMarkedItemsExactly(), OGL_draw_half_open_cylinder(), EAGLE_PLUGIN::packagePad(), EAGLE_PLUGIN::packageSMD(), GPCB_FPL_CACHE::parseMODULE(), PCB_PARSER::parseMODULE_unchecked(), PCB_BASE_FRAME::PlacePad(), PCB_BASE_FRAME::PlaceTexteModule(), BRDITEMS_PLOTTER::Plot_1_EdgeModule(), TEXTE_PCB::Rotate(), SCH_JUNCTION::Rotate(), MARKER_PCB::Rotate(), PCB_TARGET::Rotate(), SCH_NO_CONNECT::Rotate(), SCH_MARKER::Rotate(), LIB_BEZIER::Rotate(), TEXTE_MODULE::Rotate(), LIB_CIRCLE::Rotate(), LIB_RECTANGLE::Rotate(), SCH_LINE::Rotate(), SCH_BUS_ENTRY_BASE::Rotate(), LIB_POLYLINE::Rotate(), TRACK::Rotate(), LIB_TEXT::Rotate(), SCH_BITMAP::Rotate(), LIB_ARC::Rotate(), SCH_FIELD::Rotate(), SCH_TEXT::Rotate(), SCH_SHEET_PIN::Rotate(), MODULE::Rotate(), DIMENSION::Rotate(), DRAWSEGMENT::Rotate(), LIB_FIELD::Rotate(), SCH_LABEL::Rotate(), SCH_GLOBALLABEL::Rotate(), SCH_HIERLABEL::Rotate(), ZONE_CONTAINER::Rotate(), LIB_PIN::Rotate(), SCH_COMPONENT::Rotate(), D_PAD::Rotate(), SCH_SHEET::Rotate(), RotatePoint(), WORKSHEET_DATAITEM_POLYPOLYGON::SetBoundingBox(), EDGE_MODULE::SetDrawCoord(), TEXTE_MODULE::SetDrawCoord(), D_PAD::SetDrawCoord(), EDGE_MODULE::SetLocalCoord(), TEXTE_MODULE::SetLocalCoord(), D_PAD::SetLocalCoord(), DRAG_SEGM_PICKER::SetTrackEndsCoordinates(), D_PAD::ShapePos(), ShowBoundingBoxMicroWaveInductor(), ShowNewEdgeModule(), PLOTTER::sketchOval(), PNS_KICAD_IFACE::syncPad(), DRC::testTexts(), TEXTE_MODULE::TextHitTest(), EDA_TEXT::TextHitTest(), TraceFilledRectangle(), DIALOG_PAD_PROPERTIES::TransferDataFromWindow(), TransformArcToPolygon(), CINFO3D_VISU::TransformArcToSegments(), TEXTE_PCB::TransformBoundingBoxWithClearanceToPolygon(), TransformCircleToPolygon(), TransformRingToPolygon(), TransformRoundedEndsSegmentToPolygon(), DRAWSEGMENT::TransformShapeWithClearanceToPolygon(), and D_PAD::TransformShapeWithClearanceToPolygon().

318 {
319  int tmp;
320 
322 
323  // Cheap and dirty optimizations for 0, 90, 180, and 270 degrees.
324  if( angle == 0 )
325  return;
326 
327  if( angle == 900 ) /* sin = 1, cos = 0 */
328  {
329  tmp = *pX;
330  *pX = *pY;
331  *pY = -tmp;
332  }
333  else if( angle == 1800 ) /* sin = 0, cos = -1 */
334  {
335  *pX = -*pX;
336  *pY = -*pY;
337  }
338  else if( angle == 2700 ) /* sin = -1, cos = 0 */
339  {
340  tmp = *pX;
341  *pX = -*pY;
342  *pY = tmp;
343  }
344  else
345  {
346  double fangle = DECIDEG2RAD( angle );
347  double sinus = sin( fangle );
348  double cosinus = cos( fangle );
349  double fpx = (*pY * sinus ) + (*pX * cosinus );
350  double fpy = (*pY * cosinus ) - (*pX * sinus );
351  *pX = KiROUND( fpx );
352  *pY = KiROUND( fpy );
353  }
354 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:222
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
void RotatePoint ( int *  pX,
int *  pY,
int  cx,
int  cy,
double  angle 
)

Definition at line 357 of file trigo.cpp.

References RotatePoint().

358 {
359  int ox, oy;
360 
361  ox = *pX - cx;
362  oy = *pY - cy;
363 
364  RotatePoint( &ox, &oy, angle );
365 
366  *pX = ox + cx;
367  *pY = oy + cy;
368 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RotatePoint ( wxPoint point,
const wxPoint centre,
double  angle 
)

Definition at line 371 of file trigo.cpp.

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

372 {
373  int ox, oy;
374 
375  ox = point->x - centre.x;
376  oy = point->y - centre.y;
377 
378  RotatePoint( &ox, &oy, angle );
379  point->x = ox + centre.x;
380  point->y = oy + centre.y;
381 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RotatePoint ( double *  pX,
double *  pY,
double  cx,
double  cy,
double  angle 
)

Definition at line 384 of file trigo.cpp.

References RotatePoint().

385 {
386  double ox, oy;
387 
388  ox = *pX - cx;
389  oy = *pY - cy;
390 
391  RotatePoint( &ox, &oy, angle );
392 
393  *pX = ox + cx;
394  *pY = oy + cy;
395 }
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:317
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
void RotatePoint ( double *  pX,
double *  pY,
double  angle 
)

Definition at line 398 of file trigo.cpp.

References DECIDEG2RAD(), and NORMALIZE_ANGLE_POS().

399 {
400  double tmp;
401 
403 
404  // Cheap and dirty optimizations for 0, 90, 180, and 270 degrees.
405  if( angle == 0 )
406  return;
407 
408  if( angle == 900 ) /* sin = 1, cos = 0 */
409  {
410  tmp = *pX;
411  *pX = *pY;
412  *pY = -tmp;
413  }
414  else if( angle == 1800 ) /* sin = 0, cos = -1 */
415  {
416  *pX = -*pX;
417  *pY = -*pY;
418  }
419  else if( angle == 2700 ) /* sin = -1, cos = 0 */
420  {
421  tmp = *pX;
422  *pX = -*pY;
423  *pY = tmp;
424  }
425  else
426  {
427  double fangle = DECIDEG2RAD( angle );
428  double sinus = sin( fangle );
429  double cosinus = cos( fangle );
430 
431  double fpx = (*pY * sinus ) + (*pX * cosinus );
432  double fpy = (*pY * cosinus ) - (*pX * sinus );
433  *pX = fpx;
434  *pY = fpy;
435  }
436 }
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:222
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
double DECIDEG2RAD(double deg)
Definition: trigo.h:195
bool SegmentIntersectsSegment ( const wxPoint a_p1_l1,
const wxPoint a_p2_l1,
const wxPoint a_p1_l2,
const wxPoint a_p2_l2 
)

Function SegmentIntersectsSegment.

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.
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 58 of file trigo.cpp.

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

Referenced by EDA_RECT::Intersects().

60 {
61 
62  //We are forced to use 64bit ints because the internal units can oveflow 32bit ints when
63  // multiplied with each other, the alternative would be to scale the units down (i.e. divide
64  // by a fixed number).
65  long long dX_a, dY_a, dX_b, dY_b, dX_ab, dY_ab;
66  long long num_a, num_b, den;
67 
68  //Test for intersection within the bounds of both line segments using line equations of the
69  // form:
70  // x_k(u_k) = u_k * dX_k + x_k(0)
71  // y_k(u_k) = u_k * dY_k + y_k(0)
72  // with 0 <= u_k <= 1 and k = [ a, b ]
73 
74  dX_a = a_p2_l1.x - a_p1_l1.x;
75  dY_a = a_p2_l1.y - a_p1_l1.y;
76  dX_b = a_p2_l2.x - a_p1_l2.x;
77  dY_b = a_p2_l2.y - a_p1_l2.y;
78  dX_ab = a_p1_l2.x - a_p1_l1.x;
79  dY_ab = a_p1_l2.y - a_p1_l1.y;
80 
81  den = dY_a * dX_b - dY_b * dX_a ;
82 
83  //Check if lines are parallel
84  if( den == 0 )
85  return false;
86 
87  num_a = dY_ab * dX_b - dY_b * dX_ab;
88  num_b = dY_ab * dX_a - dY_a * dX_ab;
89 
90  //We wont calculate directly the u_k of the intersection point to avoid floating point
91  // division but they could be calculated with:
92  // u_a = (float) num_a / (float) den;
93  // u_b = (float) num_b / (float) den;
94 
95  if( den < 0 )
96  {
97  den = -den;
98  num_a = -num_a;
99  num_b = -num_b;
100  }
101 
102  //Test sign( u_a ) and return false if negative
103  if( num_a < 0 )
104  return false;
105 
106  //Test sign( u_b ) and return false if negative
107  if( num_b < 0 )
108  return false;
109 
110  //Test to ensure (u_a <= 1)
111  if( num_a > den )
112  return false;
113 
114  //Test to ensure (u_b <= 1)
115  if( num_b > den )
116  return false;
117 
118  return true;
119 }
static double square ( int  x)
inlinestatic

Definition at line 138 of file trigo.cpp.

Referenced by dummy(), mpLayer::GetColourSquare(), and TestSegmentHit().

139 {
140  return (double) x * x;
141 }
bool TestSegmentHit ( const wxPoint aRefPoint,
wxPoint  aStart,
wxPoint  aEnd,
int  aDist 
)

Function TestSegmentHit test for hit on line segment i.e.

a reference point is within a given distance from segment

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 142 of file trigo.cpp.

References abs, dist, square(), wxPoint::x, and wxPoint::y.

Referenced by convex2pointDRC(), LIB_RECTANGLE::HitTest(), LIB_BEZIER::HitTest(), LIB_POLYLINE::HitTest(), SCH_BUS_ENTRY_BASE::HitTest(), SCH_LINE::HitTest(), WS_DRAW_ITEM_LINE::HitTest(), DRAWSEGMENT::HitTest(), DIMENSION::HitTest(), TRACK::HitTest(), GERBER_DRAW_ITEM::HitTest(), WS_DRAW_ITEM_RECT::HitTest(), D_PAD::HitTest(), and LocateIntrusion().

144 {
145  // test for vertical or horizontal segment
146  if( aEnd.x == aStart.x )
147  {
148  // vertical segment
149  int ll = abs( aRefPoint.x - aStart.x );
150 
151  if( ll > aDist )
152  return false;
153 
154  // To have only one case to examine, ensure aEnd.y > aStart.y
155  if( aEnd.y < aStart.y )
156  std::swap( aStart.y, aEnd.y );
157 
158  if( aRefPoint.y <= aEnd.y && aRefPoint.y >= aStart.y )
159  return true;
160 
161  // there is a special case: x,y near an end point (distance < dist )
162  // the distance should be carefully calculated
163  if( (aStart.y - aRefPoint.y) < aDist )
164  {
165  double dd = square( aRefPoint.x - aStart.x) +
166  square( aRefPoint.y - aStart.y );
167  if( dd <= square( aDist ) )
168  return true;
169  }
170 
171  if( (aRefPoint.y - aEnd.y) < aDist )
172  {
173  double dd = square( aRefPoint.x - aEnd.x ) +
174  square( aRefPoint.y - aEnd.y );
175  if( dd <= square( aDist ) )
176  return true;
177  }
178  }
179  else if( aEnd.y == aStart.y )
180  {
181  // horizontal segment
182  int ll = abs( aRefPoint.y - aStart.y );
183 
184  if( ll > aDist )
185  return false;
186 
187  // To have only one case to examine, ensure xf > xi
188  if( aEnd.x < aStart.x )
189  std::swap( aStart.x, aEnd.x );
190 
191  if( aRefPoint.x <= aEnd.x && aRefPoint.x >= aStart.x )
192  return true;
193 
194  // there is a special case: x,y near an end point (distance < dist )
195  // the distance should be carefully calculated
196  if( (aStart.x - aRefPoint.x) <= aDist )
197  {
198  double dd = square( aRefPoint.x - aStart.x ) +
199  square( aRefPoint.y - aStart.y );
200  if( dd <= square( aDist ) )
201  return true;
202  }
203 
204  if( (aRefPoint.x - aEnd.x) <= aDist )
205  {
206  double dd = square( aRefPoint.x - aEnd.x ) +
207  square( aRefPoint.y - aEnd.y );
208  if( dd <= square( aDist ) )
209  return true;
210  }
211  }
212  else
213  {
214  // oblique segment:
215  // First, we need to calculate the distance between the point
216  // and the line defined by aStart and aEnd
217  // this dist should be < dist
218  //
219  // find a,slope such that aStart and aEnd lie on y = a + slope*x
220  double slope = (double) (aEnd.y - aStart.y) / (aEnd.x - aStart.x);
221  double a = (double) aStart.y - slope * aStart.x;
222  // find c,orthoslope such that (x,y) lies on y = c + orthoslope*x,
223  // where orthoslope=(-1/slope)
224  // to calculate xp, yp = near point from aRefPoint
225  // which is on the line defined by aStart, aEnd
226  double orthoslope = -1.0 / slope;
227  double c = (double) aRefPoint.y - orthoslope * aRefPoint.x;
228  // find nearest point to (x,y) on line defined by aStart, aEnd
229  double xp = (a - c) / (orthoslope - slope);
230  double yp = a + slope * xp;
231  // find distance to line, in fact the square of dist,
232  // because we just know if it is > or < aDist
233  double dd = square( aRefPoint.x - xp ) + square( aRefPoint.y - yp );
234  double dist = square( aDist );
235 
236  if( dd > dist ) // this reference point is not a good candiadte.
237  return false;
238 
239  // dd is < dist, therefore we should make a fine test
240  if( fabs( slope ) > 0.7 )
241  {
242  // line segment more vertical than horizontal
243  if( (aEnd.y > aStart.y && yp <= aEnd.y && yp >= aStart.y) ||
244  (aEnd.y < aStart.y && yp >= aEnd.y && yp <= aStart.y) )
245  return true;
246  }
247  else
248  {
249  // line segment more horizontal than vertical
250  if( (aEnd.x > aStart.x && xp <= aEnd.x && xp >= aStart.x) ||
251  (aEnd.x < aStart.x && xp >= aEnd.x && xp <= aStart.x) )
252  return true;
253  }
254 
255  // Here, the test point is still a good candidate,
256  // however it is not "between" the end points of the segment.
257  // It is "outside" the segment, but it could be near a segment end point
258  // Therefore, we test the dist from the test point to each segment end point
259  dd = square( aRefPoint.x - aEnd.x ) + square( aRefPoint.y - aEnd.y );
260  if( dd <= dist )
261  return true;
262  dd = square( aRefPoint.x - aStart.x ) + square( aRefPoint.y - aStart.y );
263  if( dd <= dist )
264  return true;
265  }
266 
267  return false; // no hit
268 }
static const int dist[10][10]
Definition: dist.cpp:57
#define abs(a)
Definition: auxiliary.h:84
static double square(int x)
Definition: trigo.cpp:138