From 3ea551246df9355530f4c0f0604a9a8042e86e27 Mon Sep 17 00:00:00 2001 From: fctom1215 <fctom1215@outlook.com> Date: 星期日, 01 三月 2020 22:49:25 +0800 Subject: [PATCH] 角度修正。 --- lib/src/main/cpp/driver_test.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-) diff --git a/lib/src/main/cpp/driver_test.cpp b/lib/src/main/cpp/driver_test.cpp index 1fccf31..321f3c5 100644 --- a/lib/src/main/cpp/driver_test.cpp +++ b/lib/src/main/cpp/driver_test.cpp @@ -877,6 +877,42 @@ // return i; // } // } + if (mapList[i].type == MAP_TYPE_CURVE) { + const int step = 10; + Polygon map; + bool enter = false; + + map.num = 1 + mapList[i].map.num / step + ((mapList[i].map.num % step == 0) ? 0 : 1); + map.num += 1 + mapList[i].map2.num / step + ((mapList[i].map2.num % step == 0) ? 0 : 1); + map.point = (PointF *) malloc(map.num * sizeof(PointF)); + + int n = 0, m = 0; + while (n < mapList[i].map.num - 1) { + map.point[m++] = mapList[i].map.point[n]; + n += step; + } + map.point[m++] = mapList[i].map.point[mapList[i].map.num - 1]; + + n = mapList[i].map2.num - 1; + while (n > 0) { + map.point[m++] = mapList[i].map2.point[n]; + n -= step; + } + map.point[m++] = mapList[i].map2.point[0]; + + if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &map) == GM_Containment) { + Line enterLine1; + + MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map2.point[0])); + + if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine1) > 0.1) + enter = true; + } + + free(map.point); + + if (enter) return i; + } } return -1; } -- Gitblit v1.8.0