Work with general quadratic curves and quadric surfaces given as implicit equation.
This submission facilitates working with quadratic curves (ellipse, parabola, hyperbola, etc.) and quadric surfaces (ellipsoid, elliptic paraboloid, hyperbolic paraboloid, hyperboloid, cone, elliptic cylinder, hyperbolic cylinder, parabolic cylinder, etc.) given with the general quadratic equation
Q(x) = x' * A * x + b' * x + c = 0
where a pseudoMatLab notation has been used. A is a symmetric NbyN matrix (N = 2 or N = 3 not necessarily invertible), b is an Nby1 column vector, and c is a scalar. The parameter x is an Nby1 column vector. Those points x that satisfy Q(x) = 0 comprise the quadratic curve or quadric surface.
The package comprises of two major components.
First, a set of functions is included for quadratic curves that identify the conic section and compute explicit parameters (semimajor axis, semiminor axis, rotation matrix, translation vector) of a conic section given with the general quadratic equation; or plot a conic section, returning a lineseries object (for circles, ellipses and parabolas) or a hggroup object (for hyperbolas).
Second, the package contains an algorithm for computing the distance from a point in 2D to a general quadratic curve defined implicitly by a seconddegree quadratic equation in two variables or from a point in 3D to a general quadric surface defined implicitly by a seconddegree quadratic equation in three variables.
Utility functions are included to manipulate matrices of symbolic variables that were used to precompute polynomials shipped with the package.
1.2  Fixed miscellaneous issues, some of which have been reported by File Exchange users. 

1.1  Added identifying degenerate cases using syntax kind = imconic(p, 0) without triggering an error. 
Inspired: Fitting quadratic curves and surfaces
Truc Le (view profile)
It's helpful
Mac (view profile)
I discovered the cause of the bug I described in my previous comment. Line 47 of imconicrotation.m does not take into account the sign of 'b' when 'a' == 'c' (i.e. pi/4 or pi/4). All that has to be done is to change
phi = 0.25*pi;
to be
phi = 0.25*pi*sign(b);
This change solves the problem. I (un)fortunately stumbled upon this due to wanting to rotate an ellipse by pi/4.
Cheers!
Mac (view profile)
I found that the imconic function incorrectly plots with, at least, the following example:
The following implicit function plots an ellipse with semimajor axis radius or 5 and semiminor axis radius of 4 and rotated 45 degrees:
20.5*x^29.0*x*y+20.5*y^2400.0
imconic(20.5, 9.0, 20.5, 0, 0, 400.0)
Produces the correct plot.
The following implicit function plots an ellipse with semimajor axis radius or 5 and semiminor axis radius of 4 and rotated 45 degrees:
20.5*x^2+9.0*x*y+20.5*y^2400.0
imconic(20.5, 9.0, 20.5, 0, 0, 400.0)
Produces the same plot as the previous implicit function. The plot should appear as shown in this EquationExplorer plot:
http://kevinmehall.net/p/equationexplorer/#20.5*x^29.0*x*y+20.5*y^2400.020.5*x^2+9.0*x*y+20.5*y^2400.0[10,10,10,10]
Daniel Lopes (view profile)
This is indeed an important package for
computer geometry. A missing link in MATLAB is provided to plot all family members of conic sections in an intuitive manner.
The code is well organized with a handful of examples.