------------------------------------------------------------------------
| 139 | |
| 140 | //------------------------------------------------------------------------ |
| 141 | void curve3_div::recursive_bezier(double x1, double y1, |
| 142 | double x2, double y2, |
| 143 | double x3, double y3, |
| 144 | unsigned level) |
| 145 | { |
| 146 | if(level > curve_recursion_limit) |
| 147 | { |
| 148 | return; |
| 149 | } |
| 150 | |
| 151 | // Calculate all the mid-points of the line segments |
| 152 | //---------------------- |
| 153 | double x12 = (x1 + x2) / 2; |
| 154 | double y12 = (y1 + y2) / 2; |
| 155 | double x23 = (x2 + x3) / 2; |
| 156 | double y23 = (y2 + y3) / 2; |
| 157 | double x123 = (x12 + x23) / 2; |
| 158 | double y123 = (y12 + y23) / 2; |
| 159 | |
| 160 | double dx = x3-x1; |
| 161 | double dy = y3-y1; |
| 162 | double d = fabs(((x2 - x3) * dy - (y2 - y3) * dx)); |
| 163 | double da; |
| 164 | |
| 165 | if(d > curve_collinearity_epsilon) |
| 166 | { |
| 167 | // Regular case |
| 168 | //----------------- |
| 169 | if(d * d <= m_distance_tolerance_square * (dx*dx + dy*dy)) |
| 170 | { |
| 171 | // If the curvature doesn't exceed the distance_tolerance value |
| 172 | // we tend to finish subdivisions. |
| 173 | //---------------------- |
| 174 | if(m_angle_tolerance < curve_angle_tolerance_epsilon) |
| 175 | { |
| 176 | m_points.add(point_d(x123, y123)); |
| 177 | return; |
| 178 | } |
| 179 | |
| 180 | // Angle & Cusp Condition |
| 181 | //---------------------- |
| 182 | da = fabs(atan2(y3 - y2, x3 - x2) - atan2(y2 - y1, x2 - x1)); |
| 183 | if(da >= pi) da = 2*pi - da; |
| 184 | |
| 185 | if(da < m_angle_tolerance) |
| 186 | { |
| 187 | // Finally we can stop the recursion |
| 188 | //---------------------- |
| 189 | m_points.add(point_d(x123, y123)); |
| 190 | return; |
| 191 | } |
| 192 | } |
| 193 | } |
| 194 | else |
| 195 | { |
| 196 | // Collinear case |
| 197 | //------------------ |
| 198 | da = dx*dx + dy*dy; |
nothing calls this directly
no test coverage detected