vxl-users

 [Vxl-users] Bug in vgl_conic.txx From: - 2007-03-07 04:18:45 ```Hi, I have been doing the odd bit of work with conics lately and I have found a small bug in the implementation of vgl_conic.txx . The bug is at lines 122 and 123 of vgl_conic.txx, they read : 00122 double ct = vcl_cos(-theta); 00123 double st = vcl_sin(-theta); but they should read : 00122 double ct = vcl_cos(theta); 00123 double st = vcl_sin(theta); To ensure that this assertion is correct I wrote the following code (you'll need to provide a range of values - data.x(), data.y(), e0, e1, angle0, or something of the like) : // Start // vgl_conic conic(vgl_homg_point_2d(data.x(), data.y()), e0, e1, angle0); vnl_matrix_fixed Cm = vgl_homg_operators_2d::matrix_from_conic(conic); Cm /= Cm(2, 2); // make some conic points - contracting them against the conic matrix for(unsigned int ii = 0; ii < 50; ii++) { double angle = ii*(2*vnl_math::pi/100); vnl_vector_fixed vect; vect[0] = e0*vcl_cos(angle0)*vcl_cos(angle) + e1*vcl_sin(angle0)*vcl_sin(angle) + data.x(); vect[1] = e1*vcl_cos(angle0)*vcl_sin(angle) - e0*vcl_sin(angle0)*vcl_cos(angle) + data.y(); vect[2] = tType(1); float error = dot_product(vect, Cm*vect); vcl_cout << "error[" << ii << "] = " << error << vcl_endl; } // End // This results in much smaller algebraic errors for the parametric points generated, once the bug is detected. Note that the parametric points are generated in precisely the same fashion of those in [void vgui_soview2D_ellipse::draw() const] to be sure. Maybe a test along these lines could be added to the vgl tests at some stage. David McKinnon... ```