File Exchange

image thumbnail

Quadratic curves and quadric surfaces in implicit form

version 1.2 (22.1 KB) by

Work with general quadratic curves and quadric surfaces given as implicit equation.

4.33333
3 Ratings

4 Downloads

Updated

View License

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 pseudo-MatLab notation has been used. A is a symmetric N-by-N matrix (N = 2 or N = 3 not necessarily invertible), b is an N-by-1 column vector, and c is a scalar. The parameter x is an N-by-1 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 second-degree quadratic equation in two variables or from a point in 3D to a general quadric surface defined implicitly by a second-degree quadratic equation in three variables.

Utility functions are included to manipulate matrices of symbolic variables that were used to pre-compute polynomials shipped with the package.

Comments and Ratings (4)

Truc Le

It's helpful

Mac

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

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 semi-major axis radius or 5 and semi-minor axis radius of 4 and rotated 45 degrees:
20.5*x^2-9.0*x*y+20.5*y^2-400.0

imconic(20.5, -9.0, 20.5, 0, 0, -400.0)
Produces the correct plot.

The following implicit function plots an ellipse with semi-major axis radius or 5 and semi-minor axis radius of 4 and rotated -45 degrees:
20.5*x^2+9.0*x*y+20.5*y^2-400.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^2-9.0*x*y+20.5*y^2-400.0|20.5*x^2+9.0*x*y+20.5*y^2-400.0|[-10,10,-10,10]

Daniel Lopes

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.

Updates

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.

MATLAB Release
MATLAB 7.10 (R2010a)
Acknowledgements

Inspired: Fitting quadratic curves and surfaces

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video