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 */
| 493 | This will be more than 1 if we have passed point2 |
| 494 | */ |
| 495 | float 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 |
no test coverage detected