Code covered by the BSD License  

Highlights from
Quadratic curves and quadric surfaces in implicit form

4.33333

4.3 | 3 ratings Rate this file 30 Downloads (last 30 days) File Size: 22.1 KB File ID: #28768

Quadratic curves and quadric surfaces in implicit form

by

 

20 Sep 2010 (Updated )

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

| Watch this File

File Information
Description

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.

Acknowledgements

This file inspired Fitting Quadratic Curves And Surfaces.

MATLAB release MATLAB 7.10 (R2010a)
Other requirements The functions in this submission should run in older MatLab releases with little or no changes.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (4)
28 Jan 2014 Truc Le

It's helpful

05 Oct 2013 Mac

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!

03 Oct 2013 Mac

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]

17 Dec 2010 Daniel Lopes

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
02 Oct 2010

Added identifying degenerate cases using syntax kind = imconic(p, 0) without triggering an error.

29 Jan 2014

Fixed miscellaneous issues, some of which have been reported by File Exchange users.

Contact us