MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / SlopesNearCollinear

Function SlopesNearCollinear

TheForceEngine/TFE_Polygon/clipper.cpp:4345–4369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4343//---------------------------------------------------------------------------
4344
4345bool SlopesNearCollinear(const IntPoint& pt1,
4346 const IntPoint& pt2, const IntPoint& pt3, double distSqrd)
4347{
4348 //this function is more accurate when the point that's geometrically
4349 //between the other 2 points is the one that's tested for distance.
4350 //ie makes it more likely to pick up 'spikes' ...
4351 if (Abs(pt1.X - pt2.X) > Abs(pt1.Y - pt2.Y))
4352 {
4353 if ((pt1.X > pt2.X) == (pt1.X < pt3.X))
4354 return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
4355 else if ((pt2.X > pt1.X) == (pt2.X < pt3.X))
4356 return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
4357 else
4358 return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
4359 }
4360 else
4361 {
4362 if ((pt1.Y > pt2.Y) == (pt1.Y < pt3.Y))
4363 return DistanceFromLineSqrd(pt1, pt2, pt3) < distSqrd;
4364 else if ((pt2.Y > pt1.Y) == (pt2.Y < pt3.Y))
4365 return DistanceFromLineSqrd(pt2, pt1, pt3) < distSqrd;
4366 else
4367 return DistanceFromLineSqrd(pt3, pt1, pt2) < distSqrd;
4368 }
4369}
4370//------------------------------------------------------------------------------
4371
4372bool PointsAreClose(IntPoint pt1, IntPoint pt2, double distSqrd)

Callers 1

CleanPolygonFunction · 0.85

Calls 2

AbsFunction · 0.85
DistanceFromLineSqrdFunction · 0.85

Tested by

no test coverage detected