diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ee82a93f..2a8948a09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Added a Euler pole velocity field (in spherical coordinates) for the continental plate, oceanic plate and mantel layer. \[Menno Fraters; 2025-08-25; [#850](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/850)\] ### Changed +- Modify the implementation of the Bezier curve to account for the special case of co-linear points. \[Daniel Douglas; 2025-01-23; [#799](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/799)\] - The tian2019 composition model now returns a mass fraction instead of a mass percentage. \[Daniel Douglas; 2024-11-12; [#767](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/767)\] - Only link to MPI libraries if the cmake variable USE_MPI has been set. No longer automatically link to MPI if MPI is found. \[Rene Gassmoeller; 2025-01-20; [#792](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/792)\] - Change the Doxygen documentation design using the Doxygen Awesome theme. Also fix the main README logo so it appears in the doxygen start page. \[Rene Gassmoeller; 2025-01-21; [#807](https://github.com/GeodynamicWorldBuilder/WorldBuilder/pull/807)\] diff --git a/include/world_builder/objects/bezier_curve.h b/include/world_builder/objects/bezier_curve.h index 79401619b..534e33aaa 100644 --- a/include/world_builder/objects/bezier_curve.h +++ b/include/world_builder/objects/bezier_curve.h @@ -66,10 +66,12 @@ namespace WorldBuilder ClosestPointOnCurve closest_point_on_curve_segment(const Point<2> &p, const bool verbose = false) const; /** - * @brief + * @brief Returns a point that lies on the bezier curve at some interval x between coordinate i and coordinate + * i + 1. If x = 0, returns point i, if x = 1, returns point i + 1. * - * @param i - * @param x + * @param i The index of the coordinate that defines the bezier curve. + * @param x The value used to determine additional points that lie on the bezier curve between coordinates i + * and i + 1 * @return Point<2> */ Point<2> operator()(const size_t i, const double x) const; @@ -79,7 +81,6 @@ namespace WorldBuilder std::vector,2 > > control_points; std::vector lengths; std::vector angles; - }; } diff --git a/source/world_builder/objects/bezier_curve.cc b/source/world_builder/objects/bezier_curve.cc index 38c974970..c075a712d 100644 --- a/source/world_builder/objects/bezier_curve.cc +++ b/source/world_builder/objects/bezier_curve.cc @@ -46,6 +46,13 @@ namespace WorldBuilder std::vector angle_constraints = angle_constraints_input; angle_constraints.resize(n_points,NaN::DQNAN); + // Whether points on the line are co-linear. If they are, this is a special case for the bezier curve. + // We determine if the points are co-linear by calculating the area of the triangle formed by the points. + // If the area is less than epsilon, the points are co-linear. + bool points_are_colinear = false; + const unsigned int max_arclength_discretization = 10; + const double epsilon = 1e-9; + // if no angle is provided, compute the angle as the average angle between the previous and next point. // The first angle points at the second point and the last angle points at the second to last point. // The check points are set at a distance of 1/10th the line length from the point in the direction of the angle. @@ -71,6 +78,13 @@ namespace WorldBuilder // Calculate the line between the current point and the following point const Point<2> P3P2 = points[p_i+1]-points[p_i]; + // Check if the points are co-linear by determining the area of the triangle + // formed by the 3 points. This is a special case of the bezier curve. + if ( std::abs(points[p_i-1][0] * (points[p_i][1] - points[p_i+1][1]) + + points[p_i][0] * (points[p_i+1][1] - points[p_i-1][1]) + + points[p_i+1][0] * (points[p_i-1][1] - points[p_i][1])) < epsilon) + points_are_colinear = true; + // Calculate the angles of the two lines determined above const double angle_p1p2 = atan2(P1P2[1],P1P2[0]); const double angle_p3p1 = atan2(P3P2[1],P3P2[0]); @@ -115,6 +129,7 @@ namespace WorldBuilder control_points[0][0][1] = sin(angles[0])*length*fraction_of_length+p1[1]; control_points[0][1][0] = cos(angles[1])*length*fraction_of_length+p2[0]; control_points[0][1][1] = sin(angles[1])*length*fraction_of_length+p2[1]; + { // Determine which side of the line the control points lie on const bool side_of_line_1 = (p1[0] - p2[0]) * (control_points[0][1][1] - p1[1]) @@ -123,12 +138,42 @@ namespace WorldBuilder const bool side_of_line_2 = (p1[0] - p2[0]) * (p3[1] - p1[1]) - (p1[1] - p2[1]) * (p3[0] - p1[0]) < 0; - if (side_of_line_1 == side_of_line_2) + + // The points are co-linear, so we need to check if the control points are within the line p1p2 + if (points_are_colinear) + { + const bool cp_1_within_p1p2 = (std::min(p1[0], p2[0]) - epsilon <= control_points[0][0][0] && control_points[0][0][0] <= std::max(p1[0], p2[0]) + epsilon) && + (std::min(p1[1], p2[1]) - epsilon <= control_points[0][0][1] && control_points[0][0][1] <= std::max(p1[1], p2[1]) + epsilon); + const bool cp_2_within_p1p2 = (std::min(p1[0], p2[0]) - epsilon <= control_points[0][1][0] && control_points[0][1][0] <= std::max(p1[0], p2[0]) + epsilon) && + (std::min(p1[1], p2[1]) - epsilon <= control_points[0][1][1] && control_points[0][1][1] <= std::max(p1[1], p2[1]) + epsilon); + // If the control points are not within the line p1p2, we need to move them within the line p1p2 + if (!cp_1_within_p1p2) + { + control_points[0][0][0] = cos(angles[0]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[0][0][1] = sin(angles[0]+Consts::PI)*length*fraction_of_length+p1[1]; + } + if (!cp_2_within_p1p2) + { + control_points[0][1][0] = cos(angles[0]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[0][1][1] = sin(angles[0]+Consts::PI)*length*fraction_of_length+p1[1]; + } + } + + else if (side_of_line_1 == side_of_line_2) { // use a 180 degree rotated angle to create this control_point control_points[0][1][0] = cos(angles[1]+Consts::PI)*length*fraction_of_length+p2[0]; control_points[0][1][1] = sin(angles[1]+Consts::PI)*length*fraction_of_length+p2[1]; } + + // There is no closed-form analytic way to express the arc-length of a cubic bezier curve. We approximate + // the arc-length by dividing the curve into 10 points and piecewise linearly connect them. We also store the + // length of the bezier curve within each of these intervals. We calculate the points that lie on the bezier + // curve using the operator function below. + for (unsigned int t_value = 1; t_value <= max_arclength_discretization; ++t_value) + { + lengths[0] = (operator()(0, static_cast (t_value)/max_arclength_discretization) - operator()(0, static_cast (t_value - 1)/max_arclength_discretization)).norm(); + } } } @@ -139,7 +184,6 @@ namespace WorldBuilder const double length = (points[p_i]-points[p_i+1]).norm(); // can be squared control_points[p_i][0][0] = cos(angles[p_i])*length*fraction_of_length+p1[0]; control_points[p_i][0][1] = sin(angles[p_i])*length*fraction_of_length+p1[1]; - { // Determine which side of the line the control points lie on const bool side_of_line_1 = (p1[0] - p2[0]) * (control_points[p_i-1][1][1] - p1[1]) @@ -148,7 +192,31 @@ namespace WorldBuilder const bool side_of_line_2 = (p1[0] - p2[0]) * (control_points[p_i][0][1] - p1[1]) - (p1[1] - p2[1]) * (control_points[p_i][0][0] - p1[0]) < 0; - if (side_of_line_1 == side_of_line_2) + + // The points are co-linear, so we need to check if the control points are within the line p1p2 + if (points_are_colinear) + { + const bool cp_1_within_p1p2 = (std::min(p1[0], p2[0]) <= control_points[p_i][0][0] && control_points[p_i][0][0] <= std::max(p1[0], p2[0])) && + (std::min(p1[1], p2[1]) <= control_points[p_i][0][1] && control_points[p_i][0][1] <= std::max(p1[1], p2[1])); + const bool cp_2_within_p1p2 = (std::min(p1[0], p2[0]) <= control_points[p_i][1][0] && control_points[p_i][1][0] <= std::max(p1[0], p2[0])) && + (std::min(p1[1], p2[1]) <= control_points[p_i][1][1] && control_points[p_i][1][1] <= std::max(p1[1], p2[1])); + // If the control points are not within the line p1p2, we need to move them within the line p1p2 + if (!cp_1_within_p1p2) + { + control_points[p_i][0][0] = cos(angles[p_i]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[p_i][0][1] = sin(angles[p_i]+Consts::PI)*length*fraction_of_length+p1[1]; + } + if (!cp_2_within_p1p2) + { + control_points[p_i][1][0] = cos(angles[p_i]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[p_i][1][1] = sin(angles[p_i]+Consts::PI)*length*fraction_of_length+p1[1]; + } + } + + // Check to see if the angles are different. If the angles are the same, points p1, p2, and p3 + // are co-linear, and therefore the control points will also be co-linear with p1, p2 and p3. This + // makes determining which 'side' the control points lie meaningless. + else if (side_of_line_1 == side_of_line_2) { // use a 180 degree rotated angle to create this control_point control_points[p_i][0][0] = cos(angles[p_i]+Consts::PI)*length*fraction_of_length+p1[0]; @@ -156,8 +224,11 @@ namespace WorldBuilder } } - control_points[p_i][1][0] = cos(angles[p_i+1])*length*fraction_of_length+points[p_i+1][0]; - control_points[p_i][1][1] = sin(angles[p_i+1])*length*fraction_of_length+points[p_i+1][1]; + if (!points_are_colinear) + { + control_points[p_i][1][0] = cos(angles[p_i+1])*length*fraction_of_length+p2[0]; + control_points[p_i][1][1] = sin(angles[p_i+1])*length*fraction_of_length+p2[1]; + } if (p_i+1 < n_points-1) { @@ -168,15 +239,53 @@ namespace WorldBuilder const bool side_of_line_2 = (p1[0] - p2[0]) * (p3[1] - p1[1]) - (p1[1] - p2[1]) * (p3[0] - p1[0]) < 0; - if (side_of_line_1 == side_of_line_2) + // The points are co-linear, so we need to check if the control points are within the line p1p2 + if (points_are_colinear) + { + const bool cp_1_within_p1p2 = (std::min(p1[0], p2[0]) <= control_points[p_i][0][0] && control_points[p_i][0][0] <= std::max(p1[0], p2[0])) && + (std::min(p1[1], p2[1]) <= control_points[p_i][0][1] && control_points[p_i][0][1] <= std::max(p1[1], p2[1])); + const bool cp_2_within_p1p2 = (std::min(p1[0], p2[0]) <= control_points[p_i][1][0] && control_points[p_i][1][0] <= std::max(p1[0], p2[0])) && + (std::min(p1[1], p2[1]) <= control_points[p_i][1][1] && control_points[p_i][1][1] <= std::max(p1[1], p2[1])); + // If the control points are not within the line p1p2, we need to move them within the line p1p2 + if (!cp_1_within_p1p2) + { + control_points[p_i][0][0] = cos(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[p_i][0][1] = sin(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p1[1]; + } + if (!cp_2_within_p1p2) + { + control_points[p_i][1][0] = cos(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p1[0]; + control_points[p_i][1][1] = sin(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p1[1]; + } + } + + // Check to see if the angles are different. If the angles are the same, points p1, p2, and p3 + // are co-linear, and therefore the control points will also be co-linear with p1, p2 and p3. This + // makes determining which 'side' the control points lie meaningless. + else if (side_of_line_1 == side_of_line_2) { // use a 180 degree rotated angle to create this control_point control_points[p_i][1][0] = cos(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p2[0]; control_points[p_i][1][1] = sin(angles[p_i+1]+Consts::PI)*length*fraction_of_length+p2[1]; } } + + // There is no closed-form analytic way to express the arc-length of a cubic bezier curve. We approximate + // the arc-length by dividing the curve into 10 points and piecewise linearly connect them. We also store the + // length of the bezier curve within each of these intervals. We calculate the points that lie on the bezier + // curve using the operator function below. + for (unsigned int t_value = 1; t_value <= max_arclength_discretization; ++t_value) + { + lengths[p_i] = (operator()(p_i, static_cast (t_value)/max_arclength_discretization) - + operator()(p_i, static_cast ((t_value - 1))/max_arclength_discretization)).norm(); + } } } + + else + { + lengths[0] = (points[0]-points[1]).norm(); + } } diff --git a/tests/gwb-dat/cartesian_fault_x_and_y_direction/screen-output.log b/tests/gwb-dat/cartesian_fault_x_and_y_direction/screen-output.log index a93276004..32abf4969 100644 --- a/tests/gwb-dat/cartesian_fault_x_and_y_direction/screen-output.log +++ b/tests/gwb-dat/cartesian_fault_x_and_y_direction/screen-output.log @@ -1,5 +1,5 @@ # x y z d g T vx vy vz c0 c1 tag --20000 90000 990000 10000 20 6.44612 7.44612 8.44612 0 1 0 +-20000 90000 990000 10000 20 6.34463 7.34463 8.34463 0 1 0 -20000 580000 990000 10000 20 4 5 6 0 1 0 -20000 910000 990000 10000 20 4 5 6 0 1 0 70000 -30000 990000 10000 10 1 2 3 1 0 0 diff --git a/tests/gwb-dat/cartesian_slab_x_and_y_direction/screen-output.log b/tests/gwb-dat/cartesian_slab_x_and_y_direction/screen-output.log index a93276004..32abf4969 100644 --- a/tests/gwb-dat/cartesian_slab_x_and_y_direction/screen-output.log +++ b/tests/gwb-dat/cartesian_slab_x_and_y_direction/screen-output.log @@ -1,5 +1,5 @@ # x y z d g T vx vy vz c0 c1 tag --20000 90000 990000 10000 20 6.44612 7.44612 8.44612 0 1 0 +-20000 90000 990000 10000 20 6.34463 7.34463 8.34463 0 1 0 -20000 580000 990000 10000 20 4 5 6 0 1 0 -20000 910000 990000 10000 20 4 5 6 0 1 0 70000 -30000 990000 10000 10 1 2 3 1 0 0 diff --git a/tests/gwb-dat/slab_interpolation_simple_CMS/screen-output.log b/tests/gwb-dat/slab_interpolation_simple_CMS/screen-output.log index 3a940944d..f1ba5a9aa 100644 --- a/tests/gwb-dat/slab_interpolation_simple_CMS/screen-output.log +++ b/tests/gwb-dat/slab_interpolation_simple_CMS/screen-output.log @@ -56,6 +56,6 @@ -104000 120000 150000 50e3 1622.56 0 0 0 -1 -14000 70000 150000 50e3 1622.56 0 0 0 -1 -163600 124000 -10 200010 1692.16 0 0 0 -1 -90000 200000 0 200000 1692.16 0 0 0 -1 +90000 200000 0 200000 600 0 0 0 0 90000 180000 0 200000 600 0 0 0 0 86000 0 0 200000 1692.16 0 0 0 -1 diff --git a/tests/gwb-dat/smooth_composition_fault/screen-output.log b/tests/gwb-dat/smooth_composition_fault/screen-output.log index e5d451157..8dbb05307 100644 --- a/tests/gwb-dat/smooth_composition_fault/screen-output.log +++ b/tests/gwb-dat/smooth_composition_fault/screen-output.log @@ -1,9 +1,9 @@ # x y z d g T vx vy vz c0 c1 tag -6371000 -24.5 -1. 0 1600 0 0 0 0.145198 0 0 +6371000 -24.5 -1. 0 1600 0 0 0 0.999675 0 0 6365000 -23. -1.3 6e3 1602.64 0 0 0 0.728204 0 0 6361000 -23.3 -1.3 10e3 1604.4 0 0 0 0.879318 0 0 6371000 -23. -1. 0 1600 0 0 0 0.999489 0 0 -6370000 -23.4 -1.66 1e3 1600.44 0 0 0 0.000138979 0 0 +6370000 -23.4 -1.66 1e3 1600.44 0 0 0 0 0 -1 6370000 -23.4 -1.45 1e3 1600.44 0 0 0 0.271888 0 0 6370000 -23.4 -1.25 1e3 1600.44 0 0 0 0.968088 0 0 6370000 -23.4 -1.0 1e3 1600.44 0 0 0 0.999865 0 0 diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Distance_to_Feature_Plane.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Distance_to_Feature_Plane.txt index ebb7e5ae7..ca366e920 100644 --- a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Distance_to_Feature_Plane.txt +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Distance_to_Feature_Plane.txt @@ -3,10 +3,10 @@ Test [0] = 7141.78 [1] = 70.7107 -[2] = 482.865 -[3] = 153.282 -[4] = 468.712 -[5] = 139.151 +[2] = 481.055 +[3] = 155.091 +[4] = 466.902 +[5] = 140.96 [6] = 1070.96 [7] = 6141.53 [8] = inf diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Fault.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Fault.txt index c9d83a613..c2debf64d 100644 --- a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Fault.txt +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Fault.txt @@ -270,37 +270,37 @@ Test [266] = 0 [267] = 0 [268] = 0 -[269] = 4.38481 -[270] = 4.38481 -[271] = 4.38481 -[272] = 4.38481 -[273] = 4.38481 -[274] = 4.38481 +[269] = 4.74577 +[270] = 4.74577 +[271] = 4.74577 +[272] = 4.74577 +[273] = 4.74577 +[274] = 4.74577 [275] = 1668.63 [276] = 1692.16 [277] = 0 [278] = 0 [279] = 0 -[280] = 0.0962028 +[280] = 0.186442 [281] = 0 [282] = 0 [283] = 0 -[284] = 0.0962028 +[284] = 0.186442 [285] = 0 [286] = 0 [287] = 0 -[288] = 0.0962028 -[289] = 0.288608 +[288] = 0.186442 +[289] = 0.559327 [290] = 0 [291] = 0 [292] = 0 -[293] = 0.0962028 -[294] = 0.288608 +[293] = 0.186442 +[294] = 0.559327 [295] = 0 [296] = 0 [297] = 0 -[298] = 0.0962028 -[299] = 0.288608 +[298] = 0.186442 +[299] = 0.559327 [300] = 0 [301] = 0 [302] = 0 @@ -311,40 +311,40 @@ Test [307] = 0 [308] = 0 [309] = 0 -[310] = 0.288608 -[311] = 0.615189 +[310] = 0.559327 +[311] = 0.25423 [312] = 0 -[313] = 4.47068 -[314] = 4.47068 -[315] = 4.47068 -[316] = 4.47068 -[317] = 4.47068 -[318] = 4.47068 +[313] = 4.80151 +[314] = 4.80151 +[315] = 4.80151 +[316] = 4.80151 +[317] = 4.80151 +[318] = 4.80151 [319] = 1668.63 [320] = 1692.16 [321] = 0 [322] = 0 [323] = 0 -[324] = 0.11767 +[324] = 0.200377 [325] = 0 [326] = 0 [327] = 0 -[328] = 0.11767 +[328] = 0.200377 [329] = 0 [330] = 0 [331] = 0 -[332] = 0.11767 -[333] = 0.35301 +[332] = 0.200377 +[333] = 0.601132 [334] = 0 [335] = 0 [336] = 0 -[337] = 0.11767 -[338] = 0.35301 +[337] = 0.200377 +[338] = 0.601132 [339] = 0 [340] = 0 [341] = 0 -[342] = 0.11767 -[343] = 0.35301 +[342] = 0.200377 +[343] = 0.601132 [344] = 0 [345] = 0 [346] = 0 @@ -355,8 +355,8 @@ Test [351] = 0 [352] = 0 [353] = 0 -[354] = 0.35301 -[355] = 0.529321 +[354] = 0.601132 +[355] = 0.198491 [356] = 0 [357] = 12 [358] = 12 @@ -364,7 +364,7 @@ Test [360] = 12 [361] = 12 [362] = 12 -[363] = 12 +[363] = 11 [364] = 11 [365] = 11 [366] = 11 @@ -372,22 +372,22 @@ Test [368] = 11 [369] = 11 [370] = 11 -[371] = 11 -[372] = 10.4159 -[373] = 10.4159 -[374] = 10.4159 -[375] = 10.4159 -[376] = 10.4159 -[377] = 10.4159 -[378] = 10.4159 +[371] = 10.1755 +[372] = 10.1755 +[373] = 10.1755 +[374] = 10.1755 +[375] = 10.1755 +[376] = 10.1755 +[377] = 10.1755 +[378] = 10 [379] = 10 [380] = 10 [381] = 10 [382] = 10 -[383] = 10.4159 -[384] = 10.4159 -[385] = 10.4159 -[386] = 10.4159 +[383] = 1654.67 +[384] = 1656.99 +[385] = 1659.31 +[386] = 1661.64 [387] = 1668.63 [388] = 1673.31 [389] = 1678 @@ -432,8 +432,8 @@ Test [428] = 0: s=0, R=1 0 0 0 1 0 0 0 1 1: s=0, R=1 0 0 0 1 0 0 0 1 2: s=0, R=1 0 0 0 1 0 0 0 1 [429] = 0: s=0.4, R=-1 0 0 0 1 0 0 0 -1 1: s=0.4, R=-1 0 0 0 1 0 0 0 -1 2: s=0.4, R=-1 0 0 0 1 0 0 0 -1 [430] = 0: s=0.4, R=-1 0 0 0 1 0 0 0 -1 1: s=0.4, R=-1 0 0 0 1 0 0 0 -1 2: s=0.4, R=-1 0 0 0 1 0 0 0 -1 -[431] = 0: s=0.276962, R=-0.734163 0 0 0 1 0 0 0 -0.734163 1: s=0.276962, R=-0.734163 0 0 0 1 0 0 0 -0.734163 2: s=0.276962, R=-0.734163 0 0 0 1 0 0 0 -0.734163 -[432] = 0: s=0.5, R=-0.871652 -0.161063 -0.462905 -0.469023 0.548252 0.692414 0.142266 0.820657 -0.553428 1: s=0.5, R=-0.272306 -0.076158 0.959192 -0.659779 -0.71083 -0.243744 0.700386 -0.699228 0.143316 -[433] = 0: s=0.666867, R=0.656083 0.703199 0.273982 -0.631041 0.710284 -0.311903 -0.413935 0.0317407 0.909753 1: s=0.333133, R=-0.63199 0.515894 -0.57831 0.774573 0.444575 -0.449878 0.0250133 -0.732261 -0.680564 -[434] = 0: s=0.668947, R=-0.566111 0.787795 -0.242688 -0.350613 -0.496563 -0.794038 -0.746048 -0.364424 0.557321 1: s=0.331053, R=0.666391 0.665895 -0.335419 -0.694912 0.391651 -0.603081 -0.270222 0.634974 0.723732 +[431] = 0: s=0.349154, R=-0.952809 0 0 0 1 0 0 0 -0.952809 1: s=0.349154, R=-0.952809 0 0 0 1 0 0 0 -0.952809 2: s=0.349154, R=-0.952809 0 0 0 1 0 0 0 -0.952809 +[432] = 0: s=0.5, R=-0.847105 -0.257589 -0.464824 -0.381113 0.904039 0.193562 0.370359 0.341117 -0.863987 1: s=0.5, R=-0.32546 -0.111865 0.938915 -0.840886 -0.419864 -0.341503 0.432419 -0.900667 0.0425834 +[433] = 0: s=0.716291, R=0.442826 0.859235 -0.256164 -0.89572 0.436659 -0.0837572 0.0398892 0.266541 0.962998 1: s=0.283709, R=-0.281792 0.702162 -0.653882 0.885702 0.452424 0.104134 0.368951 -0.549801 -0.749396 +[434] = 0: s=0.668172, R=-0.421933 0.905853 0.0374546 -0.751694 -0.326433 -0.57306 -0.506882 -0.269947 0.818657 1: s=0.331828, R=0.664415 0.422105 -0.616749 -0.747268 0.388387 -0.539208 0.0119345 0.819136 0.573476 diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Subducting_Plate.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Subducting_Plate.txt index 302eaf271..547fc271f 100644 --- a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Subducting_Plate.txt +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Features__Subducting_Plate.txt @@ -65,13 +65,13 @@ Test [61] = 1600.45 [62] = 1602.24 [63] = 1604.49 -[64] = 10 +[64] = 1611.24 [65] = 10 [66] = 10 [67] = 11 [68] = 11 [69] = 1692.16 -[70] = 1 +[70] = 1600 [71] = 1.00008 [72] = 1.00042 [73] = 1.00085 @@ -87,7 +87,7 @@ Test [83] = 0 [84] = 0 [85] = 0 -[86] = 1 +[86] = 0 [87] = 0 [88] = 0 [89] = 0 @@ -187,11 +187,11 @@ Test [183] = 0 [184] = 1600 [185] = 1600 -[186] = 4.38481 -[187] = 4.38481 -[188] = 4.38481 -[189] = 4.38481 -[190] = 4.38481 +[186] = 4.74577 +[187] = 4.74577 +[188] = 4.74577 +[189] = 4.74577 +[190] = 4.74577 [191] = 1692.16 [192] = 0 [193] = 0 @@ -204,23 +204,23 @@ Test [200] = 0 [201] = 0 [202] = 0 -[203] = 0.0962028 -[204] = 0.288608 +[203] = 0.186442 +[204] = 0.559327 [205] = 0 [206] = 0 [207] = 0 -[208] = 0.0962028 -[209] = 0.288608 +[208] = 0.186442 +[209] = 0.559327 [210] = 0 [211] = 0 [212] = 0 -[213] = 0.0962028 -[214] = 0.288608 +[213] = 0.186442 +[214] = 0.559327 [215] = 0 [216] = 0 [217] = 0 -[218] = 0.0962028 -[219] = 0.288608 +[218] = 0.186442 +[219] = 0.559327 [220] = 0 [221] = 0 [222] = 0 @@ -231,11 +231,11 @@ Test [227] = 0 [228] = 1600 [229] = 1600 -[230] = 4.47068 -[231] = 4.47068 -[232] = 4.47068 -[233] = 4.47068 -[234] = 4.47068 +[230] = 4.80151 +[231] = 4.80151 +[232] = 4.80151 +[233] = 4.80151 +[234] = 4.80151 [235] = 1692.16 [236] = 0 [237] = 0 @@ -248,23 +248,23 @@ Test [244] = 0 [245] = 0 [246] = 0 -[247] = 0.11767 -[248] = 0.35301 +[247] = 0.200377 +[248] = 0.601132 [249] = 0 [250] = 0 [251] = 0 -[252] = 0.11767 -[253] = 0.35301 +[252] = 0.200377 +[253] = 0.601132 [254] = 0 [255] = 0 [256] = 0 -[257] = 0.11767 -[258] = 0.35301 +[257] = 0.200377 +[258] = 0.601132 [259] = 0 [260] = 0 [261] = 0 -[262] = 0.11767 -[263] = 0.35301 +[262] = 0.200377 +[263] = 0.601132 [264] = 0 [265] = 0 [266] = 0 @@ -278,7 +278,7 @@ Test [274] = 10 [275] = 11 [276] = 11 -[277] = 1716.01 +[277] = 12 [278] = 1740.21 [279] = 1600 [280] = 0 diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_1.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_1.txt index a77d31ecc..8639508ea 100644 --- a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_1.txt +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_1.txt @@ -171,43 +171,43 @@ TITLE [167] = test 176: 0.0176777 [168] = test 177: 1 [169] = test 178: 14.1421 -[170] = test 179: 0.597436 +[170] = test 179: 0.822535 [171] = test 180: 1 [172] = test 181: 0 [173] = test 182: 0 [174] = test 183: 1 [175] = test 184: 10.8239 -[176] = test 185: 0.5 +[176] = test 185: 0.822535 [177] = test 186: 0 [178] = test 187: 0 [179] = test 188: 0.765367 -[180] = test 189: -0.460073 -[181] = test 190: 12.0181 -[182] = test 191: 0.597436 +[180] = test 189: -1.51925 +[181] = test 190: 11.9306 +[182] = test 191: 0.822535 [183] = test 192: 1 [184] = test 193: 0 -[185] = test 194: 0.849808 +[185] = test 194: 0.843618 [186] = test 195: 0 [187] = test 196: 14.1421 [188] = test 197: 1 [189] = test 198: 1 [190] = test 199: 0 [191] = test 200: 1 -[192] = test 201: 0 +[192] = test 201: -9.49552e-11 [193] = test 202: 100 -[194] = test 203: 0.5 +[194] = test 203: 0.822535 [195] = test 204: 0 [196] = test 205: 0 [197] = test 206: 1 -[198] = test 207: 0 +[198] = test 207: -9.49552e-11 [199] = test 208: 101 -[200] = test 209: 0.5 +[200] = test 209: 0.822535 [201] = test 210: 0 [202] = test 211: 1 [203] = test 212: 0.01 -[204] = test 213: 0 +[204] = test 213: -9.49552e-11 [205] = test 214: 200 -[206] = test 215: 0.5 +[206] = test 215: 0.822535 [207] = test 216: 0 [208] = test 217: 1 [209] = test 218: 1 @@ -220,16 +220,16 @@ TITLE [216] = test 225: 0 [217] = test 226: 0 [218] = test 227: 75 -[219] = test 228: 0.597436 +[219] = test 228: 0.822535 [220] = test 229: 1 [221] = test 230: 1 -[222] = test 231: 0.0694698 +[222] = test 231: 0.273923 [223] = test 232: 0 [224] = test 233: 76 -[225] = test 234: 0.597436 +[225] = test 234: 0.822535 [226] = test 235: 1 [227] = test 236: 1 -[228] = test 237: 0.0837294 +[228] = test 237: 0.290909 [229] = test 238: 0 [230] = test 239: inf [231] = test 240: 0 diff --git a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_2.txt b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_2.txt index f419e1da2..9b9ab66f9 100644 --- a/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_2.txt +++ b/tests/unit_tests/approval_tests/approved/unit_test_world_builder.WorldBuilder_Utilities_function__distance_point_from_curved_planes_cartesian_part_2.txt @@ -3,46 +3,46 @@ TITLE [0] = 1 [1] = 15.708 -[2] = 0.5 +[2] = 0.822535 [3] = 0 [4] = 1 [5] = 1 [6] = 10 [7] = 5 [8] = 15.708 -[9] = 0.5 +[9] = 0.822535 [10] = 0 [11] = 1 [12] = 1 [13] = 10 [14] = -5 [15] = 15.708 -[16] = 0.5 +[16] = 0.822535 [17] = 0 [18] = 1 [19] = 1 [20] = 10 [21] = 0 [22] = 7.85398 -[23] = 0.5 +[23] = 0.822535 [24] = 0 [25] = 0 [26] = 1 [27] = 2.92893 [28] = -10 [29] = 7.85398 -[30] = 0.5 +[30] = 0.822535 [31] = 0 [32] = 0 [33] = 1 [34] = 2.92893 [35] = 0 [36] = 0 -[37] = 0.5 +[37] = 0.822535 [38] = 0 -[39] = 0 -[40] = 0 -[41] = 0 +[39] = 1 +[40] = 1 +[41] = 10 [42] = 1 [43] = 1 [44] = 0 @@ -52,111 +52,111 @@ TITLE [48] = 0 [49] = 0 [50] = 7.85398 -[51] = 0.5 +[51] = 0.822535 [52] = 0 [53] = 1 [54] = 1 [55] = 5 [56] = 0 [57] = 3.92699 -[58] = 0.5 +[58] = 0.822535 [59] = 0 [60] = 0 [61] = 1 [62] = 0 [63] = 15.708 -[64] = 0.5 +[64] = 0.822535 [65] = 0 [66] = 0 [67] = 1 [68] = 0 [69] = 7.85398 -[70] = 0.5 +[70] = 0.822535 [71] = 0 [72] = 0 [73] = 0.5 [74] = 0 [75] = 23.5619 -[76] = 0.5 +[76] = 0.822535 [77] = 0 [78] = 1 [79] = 0.5 [80] = 17.0711 [81] = 0 [82] = 0 -[83] = 0.5 +[83] = 0.822535 [84] = 0 [85] = 1 [86] = 1 [87] = 0 [88] = 15.708 -[89] = 0.5 +[89] = 0.822535 [90] = 0 [91] = 0 [92] = 0.5 [93] = 0 [94] = 31.4159 -[95] = 0.5 +[95] = 0.822535 [96] = 0 [97] = 0 [98] = 1 [99] = -1 [100] = 31.4159 -[101] = 0.5 +[101] = 0.822535 [102] = 0 [103] = 0 [104] = 1 [105] = 1 [106] = 31.4159 -[107] = 0.5 +[107] = 0.822535 [108] = 0 [109] = 0 [110] = 1 [111] = 0 [112] = 47.1239 -[113] = 0.5 +[113] = 0.822535 [114] = 0 [115] = 1 [116] = 1 [117] = -1 [118] = 47.1239 -[119] = 0.5 +[119] = 0.822535 [120] = 0 [121] = 1 [122] = 1 [123] = 1 [124] = 47.1239 -[125] = 0.5 +[125] = 0.822535 [126] = 0 [127] = 1 [128] = 1 [129] = 0 [130] = 15.708 -[131] = 0.5 +[131] = 0.822535 [132] = 0 [133] = 0 [134] = 0.333333 [135] = 0 [136] = 31.4159 -[137] = 0.5 +[137] = 0.822535 [138] = 0 [139] = 0 [140] = 0.666667 [141] = 0 [142] = 47.1239 -[143] = 0.5 +[143] = 0.822535 [144] = 0 [145] = 0 [146] = 1 [147] = 0 [148] = 54.9779 -[149] = 0.5 +[149] = 0.822535 [150] = 0 [151] = 1 [152] = 1 [153] = -7.32051 [154] = 9.55317 -[155] = 0.5 +[155] = 0.822535 [156] = 0 [157] = 1 [158] = 0.216347 @@ -168,103 +168,103 @@ TITLE [164] = 0 [165] = 2.34633 [166] = 11.781 -[167] = 0.5 +[167] = 0.822535 [168] = 0 [169] = 1 [170] = 0.5 -[171] = 0 -[172] = 15.708 -[173] = 0.5 +[171] = 2.37085 +[172] = 16.6047 +[173] = 0.822535 [174] = 0 [175] = 0 -[176] = 0.666667 +[176] = 0.704726 [177] = 0 [178] = 15.708 -[179] = 0.5 +[179] = 0.822535 [180] = 0 [181] = 0 [182] = 1 [183] = 0 [184] = 0 -[185] = 0.5 +[185] = 0.822535 [186] = 0 [187] = 1 [188] = 1 [189] = 0 [190] = 23.5619 -[191] = 0.5 +[191] = 0.822535 [192] = 0 [193] = 1 [194] = 0.5 [195] = 0 [196] = 15.7254 -[197] = 0.5 +[197] = 0.822535 [198] = 0 [199] = 1 [200] = 0.00111111 [201] = 0 [202] = 15.7081 -[203] = 0.5 +[203] = 0.822535 [204] = 0 [205] = 1 [206] = 1.11111e-05 [207] = 1 [208] = 7.85398 -[209] = 0.5 +[209] = 0.822535 [210] = 0 [211] = 0 [212] = 0 [213] = 1 [214] = 7.85398 -[215] = 0.5 +[215] = 0.822535 [216] = 0 [217] = 0 [218] = 0 [219] = 1 [220] = 7.85398 -[221] = 0.5 +[221] = 0.822535 [222] = 0 [223] = 0 [224] = 0 [225] = 1 [226] = 8.02851 -[227] = 0.5 +[227] = 0.822535 [228] = 0 [229] = 1 [230] = 0.0222222 [231] = 0.0697228 [232] = 7.95708 -[233] = 0.5 +[233] = 0.822535 [234] = 0 [235] = 1 [236] = 0.0131266 [237] = -0.0692053 [238] = 8.10095 -[239] = 0.5 +[239] = 0.822535 [240] = 0 [241] = 1 [242] = 0.031445 [243] = 0 [244] = 0 -[245] = 0.5 +[245] = 0.822535 [246] = 0 [247] = 1 [248] = 1 [249] = 0 [250] = 0 -[251] = 0.5 +[251] = 0.822535 [252] = 0 [253] = 0 [254] = 0 [255] = 0 [256] = 0 -[257] = 0.5 +[257] = 0.822535 [258] = 0 [259] = 0 [260] = 0 -[261] = 1 -[262] = 1 -[263] = 0.714955 +[261] = 0 +[262] = 0 +[263] = 0 [264] = 0 [265] = 0 [266] = 0 @@ -276,7 +276,7 @@ TITLE [272] = 0 [273] = 0 [274] = 0 -[275] = 0.597436 +[275] = 0.822535 [276] = 1 [277] = 0 [278] = 0 diff --git a/tests/unit_tests/unit_test_world_builder.cc b/tests/unit_tests/unit_test_world_builder.cc index 9e76f214e..ba2a1f4c7 100644 --- a/tests/unit_tests/unit_test_world_builder.cc +++ b/tests/unit_tests/unit_test_world_builder.cc @@ -5056,7 +5056,6 @@ TEST_CASE("GWB Bezier curve") approval_tests.emplace_back(std::make_pair("",bezier_curve(1,1.0))); approval_tests.emplace_back(std::make_pair("",bezier_curve(1,1.1))); - const Objects::BezierCurve bezier_curve_defined(coordinates, { 0.,Consts::PI,0. @@ -6043,6 +6042,7 @@ TEST_CASE("WorldBuilder Utilities function: distance_point_from_curved_planes ca approval_tests.emplace_back(std::make_pair("272",static_cast(distance_from_planes.segment))); approval_tests.emplace_back(std::make_pair("273",std::fabs(distance_from_planes.fraction_of_segment) > 1e-12 ? distance_from_planes.fraction_of_segment : 0.)); // to make sure the approval test have the same characters for very small numbers + std::vector approvals; for (auto&& value : approval_tests) {