compute the signed area of a triangle
| 281 | |
| 282 | // compute the signed area of a triangle |
| 283 | double 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 |
| 298 | bool isCCW(const Coordinate first_coordinate, |