MCPcopy Create free account
hub / github.com/Project-OSRM/osrm-backend / signedArea

Function signedArea

src/util/coordinate_calculation.cpp:283–295  ·  view source on GitHub ↗

compute the signed area of a triangle

Source from the content-addressed store, hash-verified

281
282// compute the signed area of a triangle
283double signedArea(const Coordinate first_coordinate,
284 const Coordinate second_coordinate,
285 const Coordinate third_coordinate)
286{
287 const auto lat_1 = static_cast<double>(toFloating(first_coordinate.lat));
288 const auto lon_1 = static_cast<double>(toFloating(first_coordinate.lon));
289 const auto lat_2 = static_cast<double>(toFloating(second_coordinate.lat));
290 const auto lon_2 = static_cast<double>(toFloating(second_coordinate.lon));
291 const auto lat_3 = static_cast<double>(toFloating(third_coordinate.lat));
292 const auto lon_3 = static_cast<double>(toFloating(third_coordinate.lon));
293 return 0.5 * (-lon_2 * lat_1 + lon_3 * lat_1 + lon_1 * lat_2 - lon_3 * lat_2 - lon_1 * lat_3 +
294 lon_2 * lat_3);
295}
296
297// check if a set of three coordinates is given in CCW order
298bool isCCW(const Coordinate first_coordinate,

Callers 1

isCCWFunction · 0.85

Calls 1

toFloatingFunction · 0.85

Tested by

no test coverage detected