create a new site where the HalfEdges el1 and el2 intersect - note that the PointVDG in the argument list is not used, don't know why it's there
| 413 | |
| 414 | //create a new site where the HalfEdges el1 and el2 intersect - note that the PointVDG in the argument list is not used, don't know why it's there |
| 415 | struct LNLib::Site* LNLib::VoronoiDiagramGenerator::intersect(struct Halfedge* el1, struct Halfedge* el2, struct PointVDG* p) |
| 416 | { |
| 417 | struct Edge* e1, * e2, * e; |
| 418 | struct Halfedge* el; |
| 419 | float d, xint, yint; |
| 420 | int right_of_site; |
| 421 | struct Site* v; |
| 422 | |
| 423 | e1 = el1->ELedge; |
| 424 | e2 = el2->ELedge; |
| 425 | if (e1 == (struct Edge*)NULL || e2 == (struct Edge*)NULL) |
| 426 | return ((struct Site*)NULL); |
| 427 | |
| 428 | //if the two edges bisect the same parent, return null |
| 429 | if (e1->reg[1] == e2->reg[1]) |
| 430 | return ((struct Site*)NULL); |
| 431 | |
| 432 | d = e1->a * e2->b - e1->b * e2->a; |
| 433 | if (-1.0e-10 < d && d < 1.0e-10) |
| 434 | return ((struct Site*)NULL); |
| 435 | |
| 436 | xint = (e1->c * e2->b - e2->c * e1->b) / d; |
| 437 | yint = (e2->c * e1->a - e1->c * e2->a) / d; |
| 438 | |
| 439 | if ((e1->reg[1]->coord.y < e2->reg[1]->coord.y) || |
| 440 | (e1->reg[1]->coord.y == e2->reg[1]->coord.y && |
| 441 | e1->reg[1]->coord.x < e2->reg[1]->coord.x)) |
| 442 | { |
| 443 | el = el1; |
| 444 | e = e1; |
| 445 | } |
| 446 | else |
| 447 | { |
| 448 | el = el2; |
| 449 | e = e2; |
| 450 | }; |
| 451 | |
| 452 | right_of_site = xint >= e->reg[1]->coord.x; |
| 453 | if ((right_of_site && el->ELpm == le) || (!right_of_site && el->ELpm == re)) |
| 454 | return ((struct Site*)NULL); |
| 455 | |
| 456 | //create a new site at the point of intersection - this is a new vector event waiting to happen |
| 457 | v = (struct Site*)getfree(&sfl); |
| 458 | v->refcnt = 0; |
| 459 | v->coord.x = xint; |
| 460 | v->coord.y = yint; |
| 461 | return(v); |
| 462 | } |
| 463 | |
| 464 | /* returns 1 if p is to right of halfedge e */ |
| 465 | int LNLib::VoronoiDiagramGenerator::right_of(struct Halfedge* el, struct PointVDG* p) |
nothing calls this directly
no outgoing calls
no test coverage detected