@@ -145,159 +145,6 @@ namespace pal
145
145
&& cross_product ( x3, y3, x4, y4, x1, y1 ) * cross_product ( x3, y3, x4, y4, x2, y2 ) < 0 );
146
146
}
147
147
148
-
149
-
150
-
151
- /*
152
- */
153
-
154
- bool computeSegIntersectionExt ( double x1, double y1, double x2, double y2, double xs1, double ys1, // 1st (segment)
155
- double x3, double y3, double x4, double y4, double xs2, double ys2, // 2nd segment
156
- double *x, double *y )
157
- {
158
- double cp1, cp2, cp3, cp4;
159
- cp1 = cross_product ( x1, y1, x2, y2, x3, y3 );
160
- cp2 = cross_product ( x1, y1, x2, y2, x4, y4 );
161
- cp3 = cross_product ( x3, y3, x4, y4, x1, y1 );
162
- cp4 = cross_product ( x3, y3, x4, y4, x2, y2 );
163
-
164
-
165
- if ( cp1 == 0 && cp2 == 0 && cp3 == 0 && cp4 == 0 )
166
- {
167
- #ifdef _DEBUG_FULL_
168
- std::cout << " coolineaire..." << std::endl;
169
- #endif
170
- return false ;
171
- }
172
-
173
- // 1 ter
174
- if ( cp1 == 0 && cp3 == 0 )
175
- {
176
- #ifdef _DEBUG_FULL_
177
- std::cout << " cp1 = cp3 = 0 => ignoring..." << std::endl;
178
- #endif
179
- return false ;
180
- }
181
-
182
- // 1 bis
183
- if ( cp1 == 0 && cp4 == 0 )
184
- {
185
- #ifdef _DEBUG_FULL_
186
- std::cout << " cp1 = cp4 = 0 => ignoring..." << std::endl;
187
- #endif
188
- return false ;
189
- }
190
-
191
- // 1 bis
192
- if ( cp2 == 0 && cp3 == 0 )
193
- {
194
- #ifdef _DEBUG_FULL_
195
- std::cout << " cp2 = cp3 = 0 => ignoring..." << std::endl;
196
- #endif
197
- return false ;
198
- }
199
-
200
- // 2bis and 3bis
201
- if ( cp1 == 0 || cp3 == 0 )
202
- {
203
- #ifdef _DEBUG_FULL_
204
- std::cout << " skip..." << std::endl;
205
- #endif
206
- return false ;
207
- }
208
-
209
- // case 3
210
- if ( cp4 == 0 && cp1 * cp1 < 0 )
211
- {
212
- if ( cross_product ( x3, y3, x4, y4, xs1, ys1 ) * cp3 < 0 )
213
- {
214
- *x = x2;
215
- *y = y2;
216
- return true ;
217
- }
218
- else
219
- return false ;
220
- }
221
-
222
- // case 2
223
- if ( cp2 == 0 && cp3 * cp4 < 0 )
224
- {
225
- if ( cross_product ( x1, y1, x2, y2, xs2, ys2 ) * cp1 < 0 )
226
- {
227
- *x = x4;
228
- *y = y4;
229
- return true ;
230
- }
231
- else
232
- return false ;
233
- }
234
-
235
- // case 1
236
- if ( cp2 == 0 && cp4 == 0 )
237
- {
238
- double distance[4 ];
239
- double cx, cy;
240
- double dx, dy;
241
- double nx[4 ], ny[4 ];
242
- double toDist;
243
- double ratio;
244
- int i;
245
-
246
- cx = x2;
247
- cy = y2;
248
-
249
- nx[0 ] = x1;
250
- ny[0 ] = y1;
251
-
252
- nx[1 ] = xs1;
253
- ny[1 ] = ys1;
254
-
255
- nx[2 ] = x3;
256
- ny[2 ] = y3;
257
-
258
- nx[3 ] = xs2;
259
- ny[3 ] = ys2;
260
-
261
- distance[0 ] = dist_euc2d ( cx, cy, x1, y1 ); // i
262
- toDist = distance[0 ];
263
-
264
- distance[1 ] = dist_euc2d ( cx, cy, xs1, ys1 );// j2
265
- toDist = qMax ( toDist, distance[1 ] );
266
-
267
- distance[2 ] = dist_euc2d ( cx, cy, x3, y3 );// k
268
- toDist = qMax ( toDist, distance[2 ] );
269
-
270
- distance[3 ] = dist_euc2d ( cx, cy, xs2, ys2 ); // l2
271
- toDist = qMax ( toDist, distance[3 ] );
272
-
273
- for ( i = 0 ; i < 4 ; i++ )
274
- {
275
- dx = nx[i] - cx;
276
- dy = ny[i] - cy;
277
-
278
- ratio = toDist / distance[i];
279
-
280
- nx[i] = cx + dx * ratio;
281
- ny[i] = cy + dy * ratio;
282
- }
283
-
284
- bool return_val = computeSegIntersection ( nx[0 ], ny[0 ], nx[1 ], ny[1 ], nx[2 ], ny[2 ], nx[3 ], ny[3 ], x, y );
285
-
286
- return return_val;
287
- }
288
-
289
- if ( cp1 * cp2 <= 0
290
- && cp3 *cp4 <= 0 )
291
- {
292
- return computeLineIntersection ( x1, y1, x2, y2, x3, y3, x4, y4, x, y );
293
- }
294
-
295
- return false ;
296
- }
297
-
298
-
299
-
300
-
301
148
/*
302
149
* \brief Intersection bw a line and a segment
303
150
* \return true if the point exist false otherwise
@@ -316,30 +163,6 @@ namespace pal
316
163
return false ;
317
164
}
318
165
319
-
320
-
321
- /*
322
- * \brief compute the point wherre two segment intersects
323
- * \return true if the point exist false otherwise
324
- */
325
-
326
- bool computeSegIntersection ( double x1, double y1, double x2, double y2, // 1st (segment)
327
- double x3, double y3, double x4, double y4, // 2nd segment
328
- double *x, double *y )
329
- {
330
- double cp1, cp2, cp3, cp4;
331
- cp1 = cross_product ( x1, y1, x2, y2, x3, y3 );
332
- cp2 = cross_product ( x1, y1, x2, y2, x4, y4 );
333
- cp3 = cross_product ( x3, y3, x4, y4, x1, y1 );
334
- cp4 = cross_product ( x3, y3, x4, y4, x2, y2 );
335
-
336
- if ( cp1 * cp2 <= 0
337
- && cp3 *cp4 <= 0 )
338
- return computeLineIntersection ( x1, y1, x2, y2, x3, y3, x4, y4, x, y );
339
-
340
- return false ;
341
- }
342
-
343
166
/*
344
167
* \brief compute the point wherre two lines intersects
345
168
* \return true if the ok false if line are parallel
0 commit comments