Code covered by the BSD License

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

Highlights from Quadratic curves and quadric surfaces in implicit form

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

Quadratic curves and quadric surfaces in implicit form

Levente Hunyadi (view profile)

20 Sep 2010 (Updated )

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

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.
Comments and Ratings (4)
28 Jan 2014 Truc Le

05 Oct 2013 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!

Comment only
03 Oct 2013 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]

17 Dec 2010 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.