43 } |
43 } |
44 else |
44 else |
45 { |
45 { |
46 //arrow keeps its position-left button |
46 //arrow keeps its position-left button |
47 |
47 |
48 // if(p.size()==2) |
48 if(p.size()==2) |
49 // { |
49 { |
50 // Gnome::Canvas::Points points; |
50 Gnome::Canvas::Points points; |
51 // my_points[0]=p[0]; |
51 my_points[0]=p[0]; |
52 // my_points[2]=p[1]; |
52 my_points[2]=p[1]; |
53 // for(int i=0;i<3;i++) |
53 for(int i=0;i<3;i++) |
54 // { |
54 { |
55 // points.push_back(my_points[i]); |
55 points.push_back(my_points[i]); |
56 // } |
56 } |
57 // property_points().set_value(points); |
57 property_points().set_value(points); |
58 // } |
58 } |
|
59 set_arrow=true; |
59 |
60 |
60 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
61 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
61 /////////// kepps shape-with angles |
62 /////////// kepps shape-with angles |
62 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
63 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
63 |
64 |
182 |
183 |
183 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
184 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
184 /////////// kepps shape-with scalar multiplication |
185 /////////// kepps shape-with scalar multiplication |
185 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
186 ////////////////////////////////////////////////////////////////////////////////////////////////////// |
186 |
187 |
187 if(p.size()==2) |
188 // if(p.size()==2) |
188 { |
189 // { |
189 //old vector from one to the other node - a |
190 // //old vector from one to the other node - a |
190 xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y()); |
191 // xy<double> a_v(my_points[2].get_x()-my_points[0].get_x(),my_points[2].get_y()-my_points[0].get_y()); |
191 //new vector from one to the other node - b |
192 // //new vector from one to the other node - b |
192 xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y()); |
193 // xy<double> b_v(p[1].get_x()-p[0].get_x(),p[1].get_y()-p[0].get_y()); |
193 |
194 |
194 //old vector from one node to the breakpoint - c |
195 // //old vector from one node to the breakpoint - c |
195 xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y()); |
196 // xy<double> c_v(my_points[1].get_x()-my_points[0].get_x(),my_points[1].get_y()-my_points[0].get_y()); |
196 |
197 |
197 //new vector from one node to the breakpoint - d - we have to calculate this one |
198 // //new vector from one node to the breakpoint - d - we have to calculate this one |
198 xy<double> d_v; |
199 // xy<double> d_v; |
199 |
200 |
200 //scalar product of a and b (old and new vector from first point to the other) |
201 // //scalar product of a and b (old and new vector from first point to the other) |
201 double sab=a_v*b_v; |
202 // double sab=a_v*b_v; |
202 //scalar product of c and d (old and new vector from first point to breakpoint) |
203 // //scalar product of c and d (old and new vector from first point to breakpoint) |
203 double scd=sab*c_v.normSquare()/a_v.normSquare(); |
204 // double scd=sab*c_v.normSquare()/a_v.normSquare(); |
204 |
205 |
205 std::cout<<" a " << a_v<<" b " <<b_v<<" c " <<c_v<<" sab " <<sab<<" scd "<<scd<<std::endl; |
206 // std::cout<<" a " << a_v<<" b " <<b_v<<" c " <<c_v<<" sab " <<sab<<" scd "<<scd<<std::endl; |
206 |
207 |
207 double a=c_v.normSquare(); |
208 // double a=c_v.normSquare(); |
208 double b=2*scd*c_v.y; |
209 // double b=2*scd*c_v.y; |
209 double c=scd*scd-b_v.normSquare()/a_v.normSquare()*c_v.normSquare()*c_v.x*c_v.x; |
210 // double c=scd*scd-b_v.normSquare()/a_v.normSquare()*c_v.normSquare()*c_v.x*c_v.x; |
210 |
211 |
211 std::cout<<" a " << a<<" b " <<b<<" c " <<c<<std::endl; |
212 // std::cout<<" a " << a<<" b " <<b<<" c " <<c<<std::endl; |
212 |
213 |
213 d_v.y=(-b-sqrt(b*b-4*a*c))/2/a; |
214 // d_v.y=(-b-sqrt(b*b-4*a*c))/2/a; |
214 |
215 |
215 if(c_v.x!=0) |
216 // if(c_v.x!=0) |
216 { |
217 // { |
217 d_v.x=(scd-c_v.y*d_v.y)/c_v.x; |
218 // d_v.x=(scd-c_v.y*d_v.y)/c_v.x; |
218 } |
219 // } |
219 else |
220 // else |
220 { |
221 // { |
221 d_v.x=my_points[1].get_x(); |
222 // d_v.x=my_points[1].get_x(); |
222 } |
223 // } |
223 |
224 |
224 std::cout<<" d " << d_v<<std::endl; |
225 // std::cout<<" d " << d_v<<std::endl; |
225 |
226 |
226 my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y()); |
227 // my_points[1]=Gnome::Art::Point(d_v.x+p[0].get_x(),d_v.y+p[0].get_y()); |
227 |
228 |
228 Gnome::Canvas::Points points; |
229 // Gnome::Canvas::Points points; |
229 for(int i=0;i<3;i++) |
230 // for(int i=0;i<3;i++) |
230 { |
231 // { |
231 points.push_back(my_points[i]); |
232 // points.push_back(my_points[i]); |
232 } |
233 // } |
233 property_points().set_value(points); |
234 // property_points().set_value(points); |
234 } |
235 // } |
235 } |
236 } |
236 if(set_arrow) |
237 if(set_arrow) |
237 { |
238 { |
238 //calculating coordinates of the direction indicator arrow |
239 //calculating coordinates of the direction indicator arrow |
239 |
240 |