Skip to content

Commit

Permalink
Add depth method: begin at end segment
Browse files Browse the repository at this point in the history
  • Loading branch information
MFraters committed Nov 6, 2021
1 parent 788a59c commit 88dc600
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions include/world_builder/coordinate_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ namespace WorldBuilder
{
angle_at_starting_point_with_surface,
angle_at_begin_segment_with_surface,
angle_at_begin_segment_applied_to_end_segment_with_surface,
continuous_angle_with_surface,
none
};
Expand Down
10 changes: 7 additions & 3 deletions source/coordinate_systems/spherical.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ namespace WorldBuilder


prm.declare_entry("depth method",
Types::String("",std::vector<std::string>({"starting point", "begin segment", "continuous"})),
R"(Which depth method to use in the spherical case. The available options are 'starting point' and 'begin segment'.)");
Types::String("",std::vector<std::string>({"starting point", "begin segment","begin at end segment", "continuous"})),
R"(Which depth method to use in the spherical case. The available options are 'starting point', )"
R"('begin segment' and 'begin at end segment'. See the manual section on coordinate systems for )"
R"(more info.)");


}
Expand All @@ -60,11 +62,13 @@ namespace WorldBuilder
used_depth_method = DepthMethod::angle_at_starting_point_with_surface;
else if (string_depth_method == "begin segment")
used_depth_method = DepthMethod::angle_at_begin_segment_with_surface;
else if (string_depth_method == "begin at end segment")
used_depth_method = DepthMethod::angle_at_begin_segment_applied_to_end_segment_with_surface;
//else if (string_depth_method == "continuous")
//used_depth_method = DepthMethod::continuous_angle_with_surface;
else
WBAssertThrow(true,"Option " << string_depth_method << " is not a valid depth method for spherical "
"coordinates. The available options are 'starting point' and 'begin segment'. "
"coordinates. The available options are 'starting point', 'begin segment' and 'begin at end segment'. "
"The option 'continuous' is not yet available.");

//std::cout << "string_depth_method = " << string_depth_method << std::endl;
Expand Down
21 changes: 15 additions & 6 deletions source/utilities.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,10 @@ namespace WorldBuilder
const DepthMethod depth_method = coordinate_system->depth_method();
WBAssertThrow(depth_method == DepthMethod::none
|| depth_method == DepthMethod::angle_at_starting_point_with_surface
|| depth_method == DepthMethod::angle_at_begin_segment_with_surface,
"Only the depth methods none, angle_at_starting_point_with_surface and "
"angle_at_begin_segment_with_surface are implemented");
|| depth_method == DepthMethod::angle_at_begin_segment_with_surface
|| depth_method == DepthMethod::angle_at_begin_segment_applied_to_end_segment_with_surface,
"Only the depth methods 'none', 'angle_at_starting_point_with_surface', 'angle_at_begin_segment_with_surface'" <<
"and 'angle_at_begin_segment_applied_to_end_segment_with_surface' are implemented.");

double min_distance_check_point_surface_2d_line = std::numeric_limits<double>::infinity();
size_t i_section_min_distance = 0;
Expand Down Expand Up @@ -892,14 +893,19 @@ namespace WorldBuilder

double total_length = 0.0;
double add_angle = 0.0;
double add_angle_correction = 0.0;
double average_angle = 0.0;
for (size_t i_segment = 0; i_segment < plane_segment_lengths[original_current_section].size(); i_segment++)
{
const size_t current_segment = i_segment;

// compute the angle between the the previous begin and end if
// the depth method is angle_at_begin_segment_with_surface.
if (i_segment != 0 && depth_method == DepthMethod::angle_at_begin_segment_with_surface)
if (i_segment != 0
&&
(depth_method == DepthMethod::angle_at_begin_segment_with_surface
||
depth_method == DepthMethod::angle_at_begin_segment_applied_to_end_segment_with_surface))
{
const double add_angle_inner = (begin_segment * end_segment) / (begin_segment.norm() * end_segment.norm());

Expand All @@ -918,7 +924,8 @@ namespace WorldBuilder
"this is probably caused by that begin and end segment are the same and round off error. "
"The value of add_angle_inner = " << add_angle_inner);

add_angle += std::acos(add_angle_inner);
add_angle_correction = std::acos(add_angle_inner);
add_angle += add_angle_correction;

WBAssert(!std::isnan(add_angle),
"Internal error: The add_angle variable is not a number: " << add_angle
Expand Down Expand Up @@ -957,7 +964,9 @@ namespace WorldBuilder
const double interpolated_angle_top = plane_segment_angles[original_current_section][current_segment][0]
+ fraction_CPL_P1P2 * (plane_segment_angles[original_next_section][current_segment][0]
- plane_segment_angles[original_current_section][current_segment][0])
+ add_angle;
+ add_angle
+ (depth_method == DepthMethod::angle_at_begin_segment_applied_to_end_segment_with_surface
&& i_segment != 0 ? -add_angle_correction: 0);

const double interpolated_angle_bottom = plane_segment_angles[original_current_section][current_segment][1]
+ fraction_CPL_P1P2 * (plane_segment_angles[original_next_section][current_segment][1]
Expand Down

0 comments on commit 88dc600

Please sign in to comment.