Path: news.mathworks.com!not-for-mail
From: "Steven Lord" <slord@mathworks.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: 3D-plotting of quadric surfaces?
Date: Mon, 28 Jan 2008 11:02:49 -0500
Organization: The MathWorks, Inc.
Lines: 48
Message-ID: <fnkub9$kqs$1@fred.mathworks.com>
References: <2008012813005216807-bastian@beckspcde>
Reply-To: "Steven Lord" <slord@mathworks.com>
NNTP-Posting-Host: lords.dhcp.mathworks.com
X-Trace: fred.mathworks.com 1201536169 21340 144.212.105.187 (28 Jan 2008 16:02:49 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 28 Jan 2008 16:02:49 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
Xref: news.mathworks.com comp.soft-sys.matlab:447949



"Bastian Stahmer" <bastian@beckspc.de> wrote in message 
news:2008012813005216807-bastian@beckspcde...
> Hello!
>
> I'm trying to plot a quadric surface, which is given in cartesian 
> coordinates. To be precise, I'm searching for a way to plot a quadric 
> surface given in the general form [1]
>
> 0 = A*X^2 + B*Y^2 + C*Z^2 + 2*D*X*Y + 2*E*X*Z + 2*F*Y*Z + 2*G*X + 2*H*Y + 
> 2*I*Z + J
>
> Depending on the values of the 10 coefficients this equation describes an 
> ellipoid, a hyperboloid, a paraboloid and so on. I tried to solve the 
> equation to z and create a surface, which works for non-complex solutions 
> but if you choose for example every coefficient to 0 and A, B, C and J to 
> 1, you get a Sphere with radius 1:

Almost.  The way you've written your equation, A = B = C = 1 and J = -1 
gives you a sphere.  You have it correctly written below.

> 0 = x^2+y^2+z^2-1
> and solved to z
>  (-x^2-y^2+1)^(1/2)
> -(-x^2-y^2+1)^(1/2)
>
> It's obvious that there are only real results for -x^2-y^2+1 > 0   -->  x 
> < 1 and y < 1. In addition to that, to fully display the sphere i'd need 
> to combine the two halves of the sphere given in the two solutions of z. 
> While this may be possible for such an easy surface as a sphere, it seems 
> impossible to me to do this for the generic equation.
>
> So my question is how to display such quadric surfaces in general form.

Rather than trying to solve the equation (which could be very difficult in 
the general case), evaluate:

fun(A, B, ...)  = A*X^2 + B*Y^2 + C*Z^2 + 2*D*X*Y + 2*E*X*Z + 2*F*Y*Z + 
2*G*X + 2*H*Y + 2*I*Z + J

on a grid created by MESHGRID, then use ISOSURFACE to plot the "3D contour" 
where fun(A, B, ...) = 0.

-- 
Steve Lord
slord@mathworks.com