MCPcopy Create free account
hub / github.com/AngusJohnson/Clipper2 / GetUnitNormal

Function GetUnitNormal

CPP/Clipper2Lib/src/clipper.offset.cpp:70–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70static PointD GetUnitNormal(const Point64& pt1, const Point64& pt2)
71{
72 if (pt1 == pt2) return PointD(0.0, 0.0);
73 double dx = static_cast<double>(pt2.x - pt1.x);
74 double dy = static_cast<double>(pt2.y - pt1.y);
75 double inverse_hypot = 1.0 / Hypot(dx, dy);
76 dx *= inverse_hypot;
77 dy *= inverse_hypot;
78 return PointD(dy, -dx);
79}
80
81inline bool AlmostZero(double value, double epsilon = 0.001)
82{

Callers 2

BuildNormalsMethod · 0.85
BuildNormalsMethod · 0.85

Calls 2

PointDClass · 0.85
HypotFunction · 0.85

Tested by

no test coverage detected