125 int* num_hull_points_left,
127 int* num_hull_points_right,
131 int left_points_counter, right_points_counter;
133 for (
int i = 0; i < num_all_points; i++)
138 SortByY(temp1, num_all_points);
140 hull_left[0] = temp1[num_all_points - 1];
141 hull_left[1] = temp1[0];
142 hull_right[0] = temp1[num_all_points - 1];
143 hull_right[1] = temp1[0];
144 float divided_x_dif =
145 (temp1[0].x - temp1[num_all_points - 1].x) / (temp1[0].y - temp1[num_all_points - 1].y);
151 left_points_counter = 0;
152 right_points_counter = 0;
153 for (
int i = 1; i < num_all_points - 1; i++)
155 if (temp1[i].
x < temp1[0].
x + (temp1[i].y - temp1[0].y) * divided_x_dif)
157 temp2[left_points_counter] = temp1[i];
158 left_points_counter++;
162 temp2[num_all_points - 1 - right_points_counter] = temp1[i];
163 right_points_counter++;
167 temp2[left_points_counter] = temp1[num_all_points - 1];
168 left_points_counter++;
169 temp2[num_all_points - 1 - right_points_counter] = temp1[num_all_points - 1];
170 right_points_counter++;
175 hull_left[2] = temp2[0];
176 for (
int i = 1; i < left_points_counter; i++)
178 while (
RightTurn(hull_left[hull_ind_l - 1], hull_left[hull_ind_l], temp2[i]))
183 hull_left[hull_ind_l] = temp2[i];
185 *num_hull_points_left = hull_ind_l + 1;
190 hull_right[2] = temp2[num_all_points - 1];
191 for (
int i = 2; i <= right_points_counter; i++)
194 hull_right[hull_ind_r - 1], hull_right[hull_ind_r], temp2[num_all_points - i]))
199 hull_right[hull_ind_r] = temp2[num_all_points - i];
201 *num_hull_points_right = hull_ind_r + 1;
342 int left_points_counter, right_points_counter;
346 pol->
hullLeft[0] = hullpoints[nPoints - 1];
348 pol->
hullRight[0] = hullpoints[nPoints - 1];
350 float divided_x_dif = (hullpoints[0].x - hullpoints[nPoints - 1].x) /
351 (hullpoints[0].y - hullpoints[nPoints - 1].y);
353 pol->
hull[0].x = hullpoints[0].x;
354 pol->
hull[0].y = hullpoints[0].y;
356 pol->
hull[nPoints - 1].x = hullpoints[nPoints - 1].x;
357 pol->
hull[nPoints - 1].y = hullpoints[nPoints - 1].y;
358 pol->
hull[nPoints - 1].z = 3;
360 left_points_counter = 2;
361 right_points_counter = 2;
362 for (
int i = 1; i < nPoints - 1; i++)
364 pol->
hull[i].x = hullpoints[i].x;
365 pol->
hull[i].y = hullpoints[i].y;
366 if (hullpoints[i].
x <
367 hullpoints[0].
x + (hullpoints[i].y - hullpoints[0].y) * divided_x_dif)
369 pol->
hullLeft[left_points_counter] = hullpoints[i];
371 left_points_counter++;
375 pol->
hullRight[right_points_counter] = hullpoints[i];
377 right_points_counter++;
381 pol->
hullLeft[left_points_counter] = hullpoints[nPoints - 1];
382 pol->
hullRight[right_points_counter] = hullpoints[nPoints - 1];
433 Vec3d* clockwiseHullPoly1,
434 Vec3d* clockwiseHullPoly2)
462 if (boolTable[j] ==
true)
464 pointAccu[pointcount] = p1->
hull[j];
487 if (boolTable[j] ==
true)
489 pointAccu[pointcount] = p2->
hull[j];
507 float x1, y1, x2, y2, x3, y3, x4, y4, c1, c2, denominator;
522 denominator = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1);
523 c1 = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denominator;
524 c2 = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denominator;
525 if (0 <= c1 && 1 >= c1 && 0 <= c2 && 1 >= c2)
527 pointAccu[pointcount].x = x1 + c1 * (x2 - x1);
528 pointAccu[pointcount].y = y1 + c1 * (y2 - y1);