@@ -387,7 +387,7 @@ namespace WorldBuilder
387387 const std::unique_ptr<CoordinateSystems::Interface> &coordinate_system,
388388 const bool only_positive,
389389 const Objects::BezierCurve &bezier_curve,
390- Point< 2 > obliquity_vector)
390+ std::vector< double > obliquity_vector)
391391 {
392392 // Initialize variables that this function will return
393393 double distance = std::numeric_limits<double >::infinity ();
@@ -431,18 +431,22 @@ namespace WorldBuilder
431431 Objects::ClosestPointOnCurve closest_point_on_curve = bezier_curve.closest_point_on_curve_segment (check_point_surface_2d);
432432 Point<2 > closest_point_on_line_2d = closest_point_on_curve.point ;
433433
434- // If the obliquity_vector is not a NAN , this means that the user has specified an obliquity vector.
434+ // If the obliquity_vector is not infinite , this means that the user has specified an obliquity vector.
435435 // This will require a potential modification of the `closest_point_on_line_2d` variable. We will take
436436 // the check point and use it with the obliquity vector to parameterize a line and see where this line
437437 // intersects the Bezier curve. If it does intersect the Bezier curve, then this intersection point will
438438 // become the new `closest_point_on_line_2d`, otherwise it will be set to NaN.
439- if (!std::isnan (obliquity_vector[0 ]))
439+ // if (obliquity_vector_point.norm() > std::numeric_limits<double>::min())
440+ if (std::isfinite (obliquity_vector[0 ]))
440441 {
442+ Point<2 > obliquity_vector_point (obliquity_vector[0 ], obliquity_vector[1 ], natural_coordinate_system);
443+ // Normalize the vector
444+ obliquity_vector_point = obliquity_vector_point / obliquity_vector_point.norm ();
445+
441446 // Check if the bezier_curve has found a point on the curve that is closest to the checkpoint (without considering the obliquity vector).
442447 // If so, we need to check whether this point is on the correct side of the curve, given the reference point.
443448 // If the bezier_curve has not found a point on the curve that is closest to the checkpoint, check to see if the point will still
444449 // intersect the trench given the obliquity_vector.
445- obliquity_vector = obliquity_vector / obliquity_vector.norm ();
446450 if (!std::isnan (closest_point_on_line_2d[0 ]))
447451 {
448452 Point<2 > check_point_surface_2d_temp_ob = check_point_surface_2d;
@@ -489,11 +493,11 @@ namespace WorldBuilder
489493 // If the sign of the dot product of the obliquity vector and the normal vector of the closest point on
490494 // the curve is positive, then we want to move along the obliquity vector in the negative direction,
491495 // otherwise in the positive direction.
492- line_factor = obliquity_vector * iterable_closest_point_on_curve.normal > 0 ? -1.0 : 1.0 ;
496+ line_factor = obliquity_vector_point * iterable_closest_point_on_curve.normal > 0 ? -1.0 : 1.0 ;
493497
494498 // Parameterize a line through the checkpoint along the obliquity vector.
495- Point<2 > parameterized_line (iterable_check_point_surface_2d[0 ] + line_factor * old_dist * obliquity_vector [0 ],
496- iterable_check_point_surface_2d[1 ] + line_factor * old_dist * obliquity_vector [1 ],
499+ Point<2 > parameterized_line (iterable_check_point_surface_2d[0 ] + line_factor * old_dist * obliquity_vector_point [0 ],
500+ iterable_check_point_surface_2d[1 ] + line_factor * old_dist * obliquity_vector_point [1 ],
497501 natural_coordinate_system);
498502
499503 // Check where the closest point on the Bezier curve is relative to the new check point (after moving along the
@@ -564,7 +568,7 @@ namespace WorldBuilder
564568 second_closest_point_idx = dist_prev < dist_next ? closest_point_idx - 1 : closest_point_idx + 1 ;
565569 }
566570
567- // const Point<2> second_closest_point = point_list[second_closest_point_idx];
571+ const Point<2 > second_closest_point = point_list[second_closest_point_idx];
568572 // std::vector<Point<2> > closest_points;
569573 // closest_points.push_back(closest_point);
570574 // closest_points.push_back(second_closest_point);
@@ -601,15 +605,15 @@ namespace WorldBuilder
601605 // If both lines are parameterized with l_i = x_i + t_i * v_i, then since we know the points x_i and the
602606 // vectors v_i, we can solve for t_1 and t_2 when l_1 = l_2. This works out to be:
603607 const double numerator = trench_uv[0 ] * (trench_point1[1 ] - check_point_surface_2d[1 ]) + trench_uv[1 ] * (check_point_surface_2d[0 ] - trench_point1[0 ]);
604- const double denominator = obliquity_vector [1 ] * trench_uv[0 ] - obliquity_vector [0 ] * trench_uv[1 ];
608+ const double denominator = obliquity_vector_point [1 ] * trench_uv[0 ] - obliquity_vector_point [0 ] * trench_uv[1 ];
605609 const double t_val = numerator / denominator;
606610
607611 // If the two lines are parallel, t_val will be infinite. Check to see that this is not the case.
608612 if (std::isfinite (t_val))
609613 {
610614 // t_val is finite, now determine where the intersection point is, and see if this lies within the trench extents.
611- const Point<2 > intersection_point (check_point_surface_2d[0 ] + t_val * obliquity_vector [0 ],
612- check_point_surface_2d[1 ] + t_val * obliquity_vector [1 ],
615+ const Point<2 > intersection_point (check_point_surface_2d[0 ] + t_val * obliquity_vector_point [0 ],
616+ check_point_surface_2d[1 ] + t_val * obliquity_vector_point [1 ],
613617 natural_coordinate_system);
614618
615619 if (intersection_point[0 ] >= min_along_x && intersection_point[0 ] <= max_along_x
0 commit comments