Ticket #86: placement-debug.patch
| File placement-debug.patch, 2.8 kB (added by artem, 8 months ago) |
|---|
-
src/placement_finder.cpp
549 549 const double initial_distance = distance; 550 550 551 551 std::auto_ptr<placement_element> current_placement(new placement_element); 552 std::cerr << std::endl << " Trying new placement at: " << index << ", distance: " << distance << std::endl; 552 553 553 554 double string_height = p.info.get_dimensions().second; 554 555 double old_x = path_positions[index-1].x; … … 561 562 double dy = new_y - old_y; 562 563 563 564 double segment_length = path_distances[index]; 564 565 565 566 current_placement->starting_x = old_x + dx*distance/segment_length; 566 567 current_placement->starting_y = old_y + dy*distance/segment_length; 567 568 double angle = atan2(-dy, dx); … … 584 585 c = ci.character; 585 586 586 587 //Coordinates this character will start at 588 std::cerr << "length:" << segment_length << std::endl; 589 assert(segment_length != 0); 587 590 double start_x = old_x + dx*distance/segment_length; 588 591 double start_y = old_y + dy*distance/segment_length; 589 592 //Coordinates this character ends at, calculated below 590 593 double end_x = 0; 591 594 double end_y = 0; 592 593 if (segment_length - distance >= ci.width) 595 596 if (segment_length - distance >= ci.width) 594 597 { 595 598 //if the distance remaining in this segment is enough, we just go further along the segment 596 599 distance += ci.width; … … 626 629 start_x, start_y, ci.width, 627 630 old_x, old_y, new_x, new_y, 628 631 end_x, end_y); //results are stored in end_x, end_y 632 assert(!isnan(end_y)); 633 assert(!isnan(end_x)); 629 634 630 635 //Need to calculate distance on the new segment 631 636 distance = sqrt(pow(old_x - end_x, 2) + pow(old_y - end_y, 2)); … … 669 674 current_placement->add_node(c,render_x - current_placement->starting_x, 670 675 -render_y + current_placement->starting_y, 671 676 render_angle); 677 std::cerr << " add_node: " << render_x << "," << current_placement->starting_x << "," << render_y << "," << current_placement->starting_y << "," << render_angle << std::endl; 672 678 673 679 //Normalise to 0 <= angle < 2PI 674 680 while (render_angle >= 2*M_PI) … … 779 785 double A = dx * dx + dy * dy; 780 786 double B = 2 * (dx * (x1 - cx) + dy * (y1 - cy)); 781 787 double C = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy) - radius * radius; 788 assert(!isnan(B)); 782 789 783 790 double det = B * B - 4 * A * C; 784 791 if (A <= 0.0000001 || det < 0)
