| | |
| | | #include <iosfwd> |
| | | #include <iomanip> |
| | | #include <sstream> |
| | | #include <vector> |
| | | |
| | | #include "../jni_log.h" |
| | | |
| | |
| | | { |
| | | return isEqual(p1.X, p2.X) && isEqual(p1.Y, p2.Y); |
| | | } |
| | | |
| | | double AvgYaw(std::vector<double> &angles) |
| | | { |
| | | double x = 0, y = 0; |
| | | double deg = 0; |
| | | |
| | | for (int i = 0; i < angles.size(); ++i) { |
| | | x += sin(toRadians(angles[i])); |
| | | y += cos(toRadians(angles[i])); |
| | | } |
| | | |
| | | if (fabs(y) <= EPSILON) { |
| | | if (x > EPSILON) { |
| | | deg = 90; |
| | | } else { |
| | | deg = 270; |
| | | } |
| | | } |
| | | else if (fabs(x) <= EPSILON) { |
| | | if (y > EPSILON) { |
| | | deg = 0; |
| | | } else { |
| | | deg = 180; |
| | | } |
| | | } else { |
| | | deg = toDegree(atan(fabs(x / y))); |
| | | |
| | | if (x < -EPSILON && y > EPSILON) { |
| | | deg = 360 - deg; |
| | | } |
| | | else if (x < -EPSILON && y < -EPSILON) { |
| | | deg = 180 + deg; |
| | | } |
| | | else if (x > EPSILON && y < -EPSILON) { |
| | | deg = 180 - deg; |
| | | } |
| | | } |
| | | |
| | | return deg; |
| | | } |