Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

## [Vxl-users] Problem with computing common tangents of two ellipses via vgl_homg_operators_2d.common_tangents(..)

 [Vxl-users] Problem with computing common tangents of two ellipses via vgl_homg_operators_2d.common_tangents(..) From: Stefan Kuhn - 2005-11-14 10:09:32 ```Hello, I tried to compute the common tangents of two ellipses by using the function common_tangents(..) in the class 'vgl_homg_operators_2d'. But the resulting lines are not the common tangents. The lines not even contact the ellipses. I have listed some lines of code to demonstrate #include #include #include #include #include main() { // Ellipse located at (1, 2) with radius x 20 and radius y 10 and theta 1 vgl_conic< double > conic1 ( vgl_homg_point_2d< double >( 1.0, 2.0, 1.0 ), 20.0, 10.0, 1.0 ); // type: real ellipse // Ellipse located at (70, 24) with radius x 40 and radius y 15 and theta 2 vgl_conic< double > conic2 ( vgl_homg_point_2d< double >( 70.0 ,24.0 ,1.0 ), 40.0, 15.0, 2.0 ); // type: real ellipse // Compute the list of tangents vgl_homg_operators_2d< double > op; vcl_list< vgl_homg_line_2d< double > > list1 = op.common_tangents( conic1, conic2 ); // Print two points of each tangent to stdout vcl_list< vgl_homg_line_2d< double > >::iterator it = list1.begin(); for( ; it != list1.end(); ++it ) { vgl_homg_line_2d< double > line = *it; vgl_homg_point_2d< double > p1; vgl_homg_point_2d< double > p2; line.get_two_points( p1, p2 ); std::cout << "p1 (homg):" << p1.x() << ", " << p1.y() << ", " << p1.w() << " p2 (homg):" << p2.x() << ", " << p2.y() << ", " << p2.w() << "\n"; std::cout << "p1 :" << (p1.x()/p1.w()) << ", " << (p1.y()/p2.w()) << " p2 :" << (p2.x()/p2.w()) << ", " << (p2.y()/p2.w()) <<"\n\n"; } } The output of these lines is: tangent 1: p1 (homg):0, -8.41586e+14, -5.3116e+13 p2 (homg):-8.41586e+14, 0, 4.45964e+13 p1 :-0, -18.8712 p2 :-18.8712, 0 tangent 2: p1 (homg):0, -1.58177e+14, 1.02222e+13 p2 (homg):-1.58177e+14, 0, -3.12009e+11 p1 :0, 506.964 p2 :506.964, -0 tangent 3: p1 (homg):0, -1.96952e+14, 1.13006e+13 p2 (homg):-1.96952e+14, 0, -1.68161e+13 p1 :0, 11.7121 p2 :11.7121, -0 tangent 4: p1 (homg):0, -7.24793e+14, -2.99222e+13 p2 (homg):-7.24793e+14, 0, -1.35194e+13 p1 :-0, 53.6113 p2 :53.6113, -0 (First the two homogenous points are listed with x, y and w; in the second line the points are listed by x/w and y/w) As we can see, all of the four lines are of the form (0,y)->(y,0). So they cannot be common tangents. Can anyone confirm this behavior? Or do I misinterpret the use of vgl_homg_operators_2d.common_tangents or the result? Tanks, Stefan (VXL-CVS-Version 1.3.0, 2005-10-29; gcc version 3.3.4; SUSE 9.2) ```

 [Vxl-users] Problem with computing common tangents of two ellipses via vgl_homg_operators_2d.common_tangents(..) From: Stefan Kuhn - 2005-11-14 10:09:32 ```Hello, I tried to compute the common tangents of two ellipses by using the function common_tangents(..) in the class 'vgl_homg_operators_2d'. But the resulting lines are not the common tangents. The lines not even contact the ellipses. I have listed some lines of code to demonstrate #include #include #include #include #include main() { // Ellipse located at (1, 2) with radius x 20 and radius y 10 and theta 1 vgl_conic< double > conic1 ( vgl_homg_point_2d< double >( 1.0, 2.0, 1.0 ), 20.0, 10.0, 1.0 ); // type: real ellipse // Ellipse located at (70, 24) with radius x 40 and radius y 15 and theta 2 vgl_conic< double > conic2 ( vgl_homg_point_2d< double >( 70.0 ,24.0 ,1.0 ), 40.0, 15.0, 2.0 ); // type: real ellipse // Compute the list of tangents vgl_homg_operators_2d< double > op; vcl_list< vgl_homg_line_2d< double > > list1 = op.common_tangents( conic1, conic2 ); // Print two points of each tangent to stdout vcl_list< vgl_homg_line_2d< double > >::iterator it = list1.begin(); for( ; it != list1.end(); ++it ) { vgl_homg_line_2d< double > line = *it; vgl_homg_point_2d< double > p1; vgl_homg_point_2d< double > p2; line.get_two_points( p1, p2 ); std::cout << "p1 (homg):" << p1.x() << ", " << p1.y() << ", " << p1.w() << " p2 (homg):" << p2.x() << ", " << p2.y() << ", " << p2.w() << "\n"; std::cout << "p1 :" << (p1.x()/p1.w()) << ", " << (p1.y()/p2.w()) << " p2 :" << (p2.x()/p2.w()) << ", " << (p2.y()/p2.w()) <<"\n\n"; } } The output of these lines is: tangent 1: p1 (homg):0, -8.41586e+14, -5.3116e+13 p2 (homg):-8.41586e+14, 0, 4.45964e+13 p1 :-0, -18.8712 p2 :-18.8712, 0 tangent 2: p1 (homg):0, -1.58177e+14, 1.02222e+13 p2 (homg):-1.58177e+14, 0, -3.12009e+11 p1 :0, 506.964 p2 :506.964, -0 tangent 3: p1 (homg):0, -1.96952e+14, 1.13006e+13 p2 (homg):-1.96952e+14, 0, -1.68161e+13 p1 :0, 11.7121 p2 :11.7121, -0 tangent 4: p1 (homg):0, -7.24793e+14, -2.99222e+13 p2 (homg):-7.24793e+14, 0, -1.35194e+13 p1 :-0, 53.6113 p2 :53.6113, -0 (First the two homogenous points are listed with x, y and w; in the second line the points are listed by x/w and y/w) As we can see, all of the four lines are of the form (0,y)->(y,0). So they cannot be common tangents. Can anyone confirm this behavior? Or do I misinterpret the use of vgl_homg_operators_2d.common_tangents or the result? Tanks, Stefan (VXL-CVS-Version 1.3.0, 2005-10-29; gcc version 3.3.4; SUSE 9.2) ```
 [Vxl-users] Re: Problem with computing common tangents of two ellipses via vgl_homg_operators_2d.common_tangents(..) From: Peter Vanroose - 2005-11-14 21:00:43 ```> std::cout << "p1 :" << (p1.x()/p1.w()) << ", " << > (p1.y()/p2.w()) << " p2 :" << (p2.x()/p2.w()) << ", " << > (p2.y()/p2.w()) <<"\n\n"; That should be "p1.y()/p1.w()" instead of "p1.y()/p2.w()". > As we can see, all of the four lines are of the form > (0,y)->(y,0). Not really: p1.y() and p2.x() are indeed identical, but p1.w() and p2.w() are different. I haven't verified the other details, so there might still be problems with the "common tangents" algorithm. -- Peter. ```
 [Vxl-users] Re: Re: Problem with computing common tangents of two ellipses via vgl_homg_operators_2d.common_tangents(..) From: Stefan Kuhn - 2005-11-15 08:15:56 ```Thank you for your fast reply! >>std::cout << "p1 :" << (p1.x()/p1.w()) << ", " << >>(p1.y()/p2.w()) << " p2 :" << (p2.x()/p2.w()) << ", " << >>(p2.y()/p2.w()) <<"\n\n"; > > > That should be "p1.y()/p1.w()" instead of "p1.y()/p2.w()". It was my mistake. Of course that should be "p1.y()/p1.w()". Now I get the correct common tangents. Regards Stefan ```