function drawconic (u)
%DRAWCONIC
%
%       drawconic (u)
%       draw solutions of x'Ax + bb'x + c = 0.
%
  A  = [u(1), u(2)/2; u(2)/2, u(3)];
  bb = [u(4); u(5)];
  c  = u(6);

  [Q D] = eig(A);
  det   = D(1,1)*D(2,2);
  if (det == 0),
    if ((D(1,1) == 0) & (D(2,2) == 0)),
      z     = -c*(bb' / norm(bb, 2));
      alpha = atan2(-bb(1), bb(2));
      drawline (z, alpha);
    else
      if (D(1,1) == 0),
        D = D*[0 1; 1 0];
        Q = Q*[0 1; 1 0];
      end
      alpha = atan2(Q(2,1), Q(1,1));
      z(1)  = bb(1)/2/D(1,1);
      a     = D(1,1)/bb(2);
      z(2)  = (z(1)^2 - c)*a;
      drawparabola (z, a, alpha);
    end
  else
    bs    = Q'*bb;
    alpha = atan2(Q(2,1), Q(1,1));
    zs    = -(2*D)\bs;  
    z     = Q*zs;
    h     = -bs'*zs/2-c;
    a     = h/D(1,1);
    b     = h/D(2,2);
    if ((a > 0) & (b > 0)),
      drawellipse (z, sqrt(a), sqrt(b), alpha);
    else
      if (a < 0),
        tmp = a;
        a = b;
        b = -a;
        alpha = alpha + pi/2;
      else
        b = -b;
      end
      drawhyperbola (z, sqrt(a), sqrt(b), alpha);
    end
  end % if

end % drawconic
    
