| 194 | } |
| 195 | |
| 196 | int VHTightenHull(ImVec2 hull[], int n, double threshold) { |
| 197 | // theory: circle the hull, compare 3 points at a time, if the mid point is |
| 198 | // sub-angular then make it equal the first point and move to the 3rd. |
| 199 | int i, ni; |
| 200 | ImVec2 *a, *b, *c; |
| 201 | double a1, a2, ad; |
| 202 | // First cycle, we look for sub-threshold 2-segment runs |
| 203 | for (i = 0; i < n; i++) { |
| 204 | a = &(hull[i]); |
| 205 | b = &(hull[(i + 1) % n]); |
| 206 | c = &(hull[(i + 2) % n]); |
| 207 | |
| 208 | a1 = VHAngleToX(*a, *b); |
| 209 | a2 = VHAngleToX(*b, *c); |
| 210 | if (a1 > a2) |
| 211 | ad = a1 - a2; |
| 212 | else |
| 213 | ad = a2 - a1; |
| 214 | |
| 215 | if (ad < threshold) { |
| 216 | // fprintf(stderr,"angle below threshold |
| 217 | //(%0.2f)\n", ad); |
| 218 | *b = *a; |
| 219 | } |
| 220 | } // end first cycle |
| 221 | |
| 222 | // Second cycle, we compact the hull |
| 223 | int output_index = 0; |
| 224 | i = 0; |
| 225 | while (i < n) { |
| 226 | ni = (i + 1) % n; |
| 227 | if ((hull[i].x == hull[ni].x) && (hull[i].y == hull[ni].y)) { |
| 228 | // match found, discard one |
| 229 | i++; |
| 230 | continue; |
| 231 | } |
| 232 | |
| 233 | hull[output_index] = hull[i]; |
| 234 | output_index++; |
| 235 | i++; |
| 236 | } |
| 237 | |
| 238 | return output_index; |
| 239 | } |
| 240 | |
| 241 | bool GetIntersection(ImVec2 p0, ImVec2 p1, ImVec2 p2, ImVec2 p3, ImVec2 *i) { |
| 242 |
nothing calls this directly
no test coverage detected