@@ -221,6 +221,29 @@ TEST(calculate_state_diff, minus_pi2_minuspi4_oriented_no_overlap) {
221221 EXPECT_NEAR (diff.angle , B_PI_2*2 /3 , 0.001 );
222222}
223223
224+ TEST (calculate_state_diff, zero_minus_3pi4_oriented_no_overlap) {
225+ // some line with three points from x=1 to x=10, y=0
226+ FrenetState state1{2.0 , 0.0 , 3.0 , 1.0 , 0.0 , 0.0 , 0.0 };
227+ FrenetState state2{11.0 , -8.0 , 1.0 , 0.0 , -3 *B_PI/4 , 0.0 , 0.0 };
228+
229+ double width1 = 2.0 , width2 = 3.0 , length1 = 5.0 , length2 = 4.0 ;
230+ const auto shape1 = Polygon (
231+ Pose (0.5 , width1/2 , 0 ),
232+ {Point2d (0 , 0 ), Point2d (0 , width1), Point2d (length1, width1),
233+ Point2d (length1, 0 ), Point2d (0 , 0 )});
234+ const auto shape2 = Polygon (
235+ Pose (0.5 , width2/2 , 0 ),
236+ {Point2d (0 , 0 ), Point2d (0 , width2), Point2d (length2, width2),
237+ Point2d (length2, 0 ), Point2d (0 , 0 )});
238+ FrenetStateDifference diff (state1, shape1, state2, shape2);
239+
240+ EXPECT_NEAR (diff.lon , 11.0 - 2.0 - 4.5 + cos (3 *B_PI/4 )*3.5 - sin (3 *B_PI/4 )*1.5 , 0.001 );
241+ EXPECT_NEAR (diff.lat , - (8.0 -1.0 - sin (3 *B_PI/4 )*3.5 + cos (3 *B_PI/4 )*1.5 ), 0.001 );
242+ EXPECT_NEAR (diff.vlat , -1.0 , 0.001 );
243+ EXPECT_NEAR (diff.vlon , -2.0 , 0.001 );
244+ EXPECT_NEAR (diff.angle , -3 *B_PI/4 , 0.001 );
245+ }
246+
224247TEST (calculate_state_diff, lateral_zero_oriented_no_overlap) {
225248 // some line with three points from x=1 to x=10, y=0
226249 FrenetState state1{1.0 , 0.0 , 3.0 , 5.0 , 0.0 , 0.0 , 0.0 };
0 commit comments