MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / line_path_proportion

Method line_path_proportion

libraries/AP_Common/Location.cpp:495–505  ·  view source on GitHub ↗

return the proportion we are along the path from point1 to point2, along a line parallel to point1<->point2. This will be more than 1 if we have passed point2 */

Source from the content-addressed store, hash-verified

493 This will be more than 1 if we have passed point2
494 */
495float Location::line_path_proportion(const Location &point1, const Location &point2) const
496{
497 const Vector2f vec1 = point1.get_distance_NE(point2);
498 const Vector2f vec2 = point1.get_distance_NE(*this);
499 const ftype dsquared = sq(vec1.x) + sq(vec1.y);
500 if (dsquared < 0.001f) {
501 // the two points are very close together
502 return 1.0f;
503 }
504 return (vec1 * vec2) / dsquared;
505}
506
507/*
508 wrap longitude for -180e7 to 180e7

Callers 6

navigateMethod · 0.80
setup_glide_slopeMethod · 0.80

Calls 2

sqFunction · 0.85
get_distance_NEMethod · 0.80

Tested by

no test coverage detected