# Changeset 93:56eb90299693 in glemon-0.x

Ignore:
Timestamp:
11/23/05 17:24:59 (19 years ago)
Branch:
gui
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk/gui@2381
Message:

No segmentation fault caused by zero long edges.

File:
1 edited

Unmodified
Added
Removed
• ## gdc-broken_edge.cc

 r89 double absb=sqrt(b_v.normSquare()); //old vector from one node to the breakpoint - c xy c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y()); //unit vector with the same direction to a_v xy a_v_u(a_v.x/absa,a_v.y/absa); //normal vector of unit vector with the same direction to a_v xy a_v_u_n(((-1)*a_v_u.y),a_v_u.x); //unit vector with the same direction to b_v xy b_v_u(b_v.x/absb,b_v.y/absb); //normal vector of unit vector with the same direction to b_v xy b_v_u_n(((-1)*b_v_u.y),b_v_u.x); //vector c in a_v_u and a_v_u_n co-ordinate system xy c_a(c_v*a_v_u,c_v*a_v_u_n); //new vector from one node to the breakpoint - d - we have to calculate this one xy d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n); my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y()); my_points[0]=p[0]; my_points[2]=p[1]; Gnome::Canvas::Points points; for(int i=0;i<3;i++) if((absa!=0)&&(absb!=0)) { points.push_back(my_points[i]); //old vector from one node to the breakpoint - c xy c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y()); //unit vector with the same direction to a_v xy a_v_u(a_v.x/absa,a_v.y/absa); //normal vector of unit vector with the same direction to a_v xy a_v_u_n(((-1)*a_v_u.y),a_v_u.x); //unit vector with the same direction to b_v xy b_v_u(b_v.x/absb,b_v.y/absb); //normal vector of unit vector with the same direction to b_v xy b_v_u_n(((-1)*b_v_u.y),b_v_u.x); //vector c in a_v_u and a_v_u_n co-ordinate system xy c_a(c_v*a_v_u,c_v*a_v_u_n); //new vector from one node to the breakpoint - d - we have to calculate this one xy d_v=absb/absa*(c_a.x*b_v_u+c_a.y*b_v_u_n); my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y()); my_points[0]=p[0]; my_points[2]=p[1]; Gnome::Canvas::Points points; for(int i=0;i<3;i++) { points.push_back(my_points[i]); } property_points().set_value(points); } property_points().set_value(points); else { //if distance is 0, segmentation would be occured //in calculations, because of division by zero //But we have luck: the edge cannot be seen in //this case, so no update needed set_arrow=false; } } } xy unit_vector_in_dir(target-center); double length=sqrt( unit_vector_in_dir.normSquare() ); //       std::cout << target << " - " << center << " = " << unit_vector_in_dir << "    / " <
Note: See TracChangeset for help on using the changeset viewer.