From 7fdc4fa80d5d04b5936fc1bdd617b64c6ae9ef37 Mon Sep 17 00:00:00 2001
From: lizhanwei <Dana_Lee1016@126.com>
Date: 星期一, 26 四月 2021 13:17:00 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/endian11/DriveJudge
---
lib/src/main/cpp/test_items/area_exam.cpp | 123 ++++++++++++++++++++++++++--------------
1 files changed, 80 insertions(+), 43 deletions(-)
diff --git a/lib/src/main/cpp/test_items/area_exam.cpp b/lib/src/main/cpp/test_items/area_exam.cpp
index f4dcce9..8c95819 100644
--- a/lib/src/main/cpp/test_items/area_exam.cpp
+++ b/lib/src/main/cpp/test_items/area_exam.cpp
@@ -226,48 +226,66 @@
return i;
}
if (mapList[i].type == MAP_TYPE_PARK_BUTTOM) {
- // 杞﹀ご椤剁偣鍦ㄥ満鍦板唴
- if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) {
- Line enterLine1, enterLine2;
+ Line triggerLine;
- MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
- MakeLine(&enterLine2, &(mapList[i].map.point[6]), &(mapList[i].map.point[7]));
+ MakeLine(&triggerLine, &(mapList[i].map.point[1]), &(mapList[i].map.point[0]));
- if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine1) > 0.1 &&
- DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine2) > 0.1)
- score[i]++;
- }
- // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
- if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
- Line enterLine1, enterLine2;
+ if (CrashTriggerLine(triggerLine, car, CarModelList))
+ return i;
- MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
- MakeLine(&enterLine2, &(mapList[i].map.point[6]), &(mapList[i].map.point[7]));
+ MakeLine(&triggerLine, &(mapList[i].map.point[7]), &(mapList[i].map.point[6]));
- if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine1) > 0.1 &&
- DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine2) > 0.1)
- score[i]++;
- }
+ if (CrashTriggerLine(triggerLine, car, CarModelList))
+ return i;
+
+// // 杞﹀ご椤剁偣鍦ㄥ満鍦板唴
+// if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) {
+// Line enterLine1, enterLine2;
+//
+// MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+// MakeLine(&enterLine2, &(mapList[i].map.point[6]), &(mapList[i].map.point[7]));
+//
+// if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine1) > 0.1 &&
+// DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine2) > 0.1)
+// score[i]++;
+// }
+// // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
+// if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
+// Line enterLine1, enterLine2;
+//
+// MakeLine(&enterLine1, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+// MakeLine(&enterLine2, &(mapList[i].map.point[6]), &(mapList[i].map.point[7]));
+//
+// if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine1) > 0.1 &&
+// DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine2) > 0.1)
+// score[i]++;
+// }
}
if (mapList[i].type == MAP_TYPE_PART_EDGE) {
- // 杞﹀ご椤剁偣鍦ㄥ満鍦板唴
- if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) {
- Line enterLine;
+ Line triggerLine;
- MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+ MakeLine(&triggerLine, &(mapList[i].map.point[1]), &(mapList[i].map.point[0]));
- if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine) > 0.1)
- score[i]++;
- }
- // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
- if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
- Line enterLine;
-
- MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
-
- if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine) > 0.1)
- score[i]++;
- }
+ if (CrashTriggerLine(triggerLine, car, CarModelList))
+ return i;
+// // 杞﹀ご椤剁偣鍦ㄥ満鍦板唴
+// if (IntersectionOf(car->carXY[ car->axial[AXIAL_FRONT] ], &mapList[i].map) == GM_Containment) {
+// Line enterLine;
+//
+// MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+//
+// if (DistanceOf(car->carXY[car->axial[AXIAL_FRONT]], enterLine) > 0.1)
+// score[i]++;
+// }
+// // 杞﹀熬椤剁偣鍦ㄥ満鍦板唴
+// if (IntersectionOf(car->carXY[ car->axial[AXIAL_REAR] ], &mapList[i].map) == GM_Containment) {
+// Line enterLine;
+//
+// MakeLine(&enterLine, &(mapList[i].map.point[0]), &(mapList[i].map.point[1]));
+//
+// if (DistanceOf(car->carXY[car->axial[AXIAL_REAR]], enterLine) > 0.1)
+// score[i]++;
+// }
}
if (mapList[i].type == MAP_TYPE_TURN_90) {
// 杞﹀墠杞垨鍚庤疆杞ㄨ抗瓒婅繃瑙﹀彂绾�
@@ -328,7 +346,7 @@
}
if (mapList[index].type == MAP_TYPE_STOP_START) {
// 鏋勯�犺櫄鎷熺殑宸︿笂瑙掔偣
- double x9, y9, xo, yo;
+ double x10, y10, x9, y9, xo, yo;
bool enter = false;
@@ -338,17 +356,33 @@
x9 = 2*xo - mapList[index].map.point[8].X;
y9 = 2*yo - mapList[index].map.point[8].Y;
+ if (mapList[index].map.num > 9) {
+ // 鏋勯�犺櫄鎷熺殑鍙充笂瑙掔偣
+ xo = (mapList[index].map.point[9].X + mapList[index].map.point[7].X) / 2;
+ yo = (mapList[index].map.point[9].Y + mapList[index].map.point[7].Y) / 2;
+ x10 = 2*xo - mapList[index].map.point[8].X;
+ y10 = 2*yo - mapList[index].map.point[8].Y;
+ }
+
Polygon map;
map.num = 4;
map.point = (PointF *) malloc(map.num * sizeof(PointF));
- map.point[0] = mapList[index].map.point[0];
- map.point[1] = mapList[index].map.point[8];
- map.point[2] = mapList[index].map.point[7];
- map.point[3].X = x9;
- map.point[3].Y = y9;
-
+ if (mapList[index].map.num <= 9) {
+ map.point[0] = mapList[index].map.point[0];
+ map.point[1] = mapList[index].map.point[8];
+ map.point[2] = mapList[index].map.point[7];
+ map.point[3].X = x9;
+ map.point[3].Y = y9;
+ } else {
+ map.point[0] = mapList[index].map.point[0];
+ map.point[1] = mapList[index].map.point[9];
+ map.point[2].X = x10;
+ map.point[2].Y = y10;
+ map.point[3].X = x9;
+ map.point[3].Y = y9;
+ }
// 鍏ㄨ溅閮介渶涓嶅湪鍦板浘涓�
Polygon carBody;
@@ -422,9 +456,12 @@
MakeLine(&trace_line, &trace.point[pp], &trace.point[p]);
MakeLine(&trace2_line, &trace2.point[pp], &trace2.point[p]);
- if ((IntersectionOf(trace_line, triggerLine) == GM_Intersection || IntersectionOf(trace2_line, triggerLine) == GM_Intersection) &&
+ if ((IntersectionOf(trace_line, triggerLine) == GM_Intersection &&
IntersectionOfLine(p1, p2, car->carXY[car->left_front_tire[TIRE_OUTSIDE]]) == -1 &&
- DistanceOf(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], triggerLine) > 0.1) {
+ DistanceOf(car->carXY[car->left_front_tire[TIRE_OUTSIDE]], triggerLine) > 0.1) ||
+ (IntersectionOf(trace2_line, triggerLine) == GM_Intersection &&
+ IntersectionOfLine(p1, p2, car->carXY[car->left_rear_tire[TIRE_OUTSIDE]]) == -1 &&
+ DistanceOf(car->carXY[car->left_rear_tire[TIRE_OUTSIDE]], triggerLine) > 0.1) ) {
// 纰板埌瑙﹀彂绾�
DEBUG("纰版挒瑙﹀彂绾� 寮曞彂鍦板浘");
trigger = true;
--
Gitblit v1.8.0