MCPcopy Create free account
hub / github.com/OpenOrienteering/mapper / parameterOfPointOnLine

Function parameterOfPointOnLine

src/util/util.cpp:161–181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

159}
160
161double parameterOfPointOnLine(double x0, double y0, double dx, double dy, double x, double y, bool& ok)
162{
163 const double epsilon = 1e-5;
164 ok = true;
165
166 if (qAbs(dx) > qAbs(dy))
167 {
168 double param = (x - x0) / dx;
169 if (qAbs(y0 + param * dy - y) < epsilon)
170 return param;
171 }
172 else if (dy != 0)
173 {
174 double param = (y - y0) / dy;
175 if (qAbs(x0 + param * dx - x) < epsilon)
176 return param;
177 }
178
179 ok = false;
180 return -1;
181}
182
183bool isPointOnSegment(const MapCoordF& seg_start, const MapCoordF& seg_end, const MapCoordF& point)
184{

Callers 2

isPointOnSegmentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected