| 377 | } |
| 378 | |
| 379 | struct LNLib::Edge* LNLib::VoronoiDiagramGenerator::bisect(struct Site* s1, struct Site* s2) |
| 380 | { |
| 381 | float dx, dy, adx, ady; |
| 382 | struct Edge* newedge; |
| 383 | |
| 384 | newedge = (struct Edge*)getfree(&efl); |
| 385 | |
| 386 | newedge->reg[0] = s1; //store the sites that this edge is bisecting |
| 387 | newedge->reg[1] = s2; |
| 388 | ref(s1); |
| 389 | ref(s2); |
| 390 | newedge->ep[0] = (struct Site*)NULL; //to begin with, there are no endpoints on the bisector - it goes to infinity |
| 391 | newedge->ep[1] = (struct Site*)NULL; |
| 392 | |
| 393 | dx = s2->coord.x - s1->coord.x; //get the difference in x dist between the sites |
| 394 | dy = s2->coord.y - s1->coord.y; |
| 395 | adx = dx > 0 ? dx : -dx; //make sure that the difference in positive |
| 396 | ady = dy > 0 ? dy : -dy; |
| 397 | newedge->c = (float)(s1->coord.x * dx + s1->coord.y * dy + (dx * dx + dy * dy) * 0.5);//get the slope of the line |
| 398 | |
| 399 | if (adx > ady) |
| 400 | { |
| 401 | newedge->a = 1.0; newedge->b = dy / dx; newedge->c /= dx;//set formula of line, with x fixed to 1 |
| 402 | } |
| 403 | else |
| 404 | { |
| 405 | newedge->b = 1.0; newedge->a = dx / dy; newedge->c /= dy;//set formula of line, with y fixed to 1 |
| 406 | }; |
| 407 | |
| 408 | newedge->edgenbr = nedges; |
| 409 | out_bisector(newedge); |
| 410 | nedges += 1; |
| 411 | return(newedge); |
| 412 | } |
| 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) |
nothing calls this directly
no outgoing calls
no test coverage detected