61 {
62
63
64
67 CT sqr_segment_length = segm_vec_x * segm_vec_x + segm_vec_y * segm_vec_y;
68
69
70
71 CT projection_start = sqr_segment_length *
73 CT projection_end = sqr_segment_length *
75 assert(projection_start != projection_end);
76
77
78
79
82 CT rot_x = segm_vec_x * point_vec_x + segm_vec_y * point_vec_y;
83 CT rot_y = segm_vec_x * point_vec_y - segm_vec_y * point_vec_x;
84
85
86 Point<CT> last_point = (*discretization)[1];
87 discretization->pop_back();
88
89
90 std::stack<CT> point_stack;
91 point_stack.push(projection_end);
92 CT cur_x = projection_start;
94
95
96 const CT max_dist_transformed = max_dist * max_dist * sqr_segment_length;
97 while (!point_stack.empty()) {
98 CT new_x = point_stack.top();
100
101
102
103 CT mid_x = (new_y - cur_y) / (new_x - cur_x) * rot_y + rot_x;
105 assert(mid_x != cur_x || mid_y != cur_y);
106 assert(mid_x != new_x || mid_y != new_y);
107
108
109
110 CT
dist = (new_y - cur_y) * (mid_x - cur_x) -
111 (new_x - cur_x) * (mid_y - cur_y);
112 CT div = (new_y - cur_y) * (new_y - cur_y) + (new_x - cur_x) * (new_x - cur_x);
113 assert(div != 0);
115 if (dist <= max_dist_transformed) {
116
117 point_stack.pop();
118 CT inter_x = (segm_vec_x * new_x - segm_vec_y * new_y) /
120 CT inter_y = (segm_vec_x * new_y + segm_vec_y * new_x) /
122 discretization->push_back(
Point<CT>(inter_x, inter_y));
123 cur_x = new_x;
124 cur_y = new_y;
125 } else {
126 point_stack.push(mid_x);
127 }
128 }
129
130
131 discretization->back() = last_point;
132 }
EIGEN_DEVICE_FUNC SegmentReturnType segment(Index start, Index n)
This is the const version of segment(Index,Index).
Definition BlockMethods.h:888
EIGEN_DEVICE_FUNC CastXpr< NewType >::Type cast() const
Definition CommonCwiseUnaryOps.h:62
static enable_if< typenamegtl_and< typenamegtl_if< typenameis_point_concept< typenamegeometry_concept< Point< int > >::type >::type >::type, typenamegtl_if< typenameis_segment_concept< typenamegeometry_concept< Segment< long > >::type >::type >::type >::type, CT >::type get_point_projection(const Point< CT > &point, const Segment< InCT > &segment)
Definition VoronoiVisualUtils.hpp:165
static CT parabola_y(CT x, CT a, CT b)
Definition VoronoiVisualUtils.hpp:136
const Scalar & y
Definition MathFunctions.h:552
T dist(const boost::polygon::point_data< T > &p1, const boost::polygon::point_data< T > &p2)
Definition Geometry.cpp:280
TCoord< P > x(const P &p)
Definition geometry_traits.hpp:297
Kernel::Point_2 Point
Definition point_areas.cpp:20