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]
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:
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.
this is not a complete solution, but maybe an idea that
will help you.
Try to parametrize your shape on its surface by placing a
new coordinate system on it. For instance, on a torus, you
could use, say, r and s, r going along the torus and s
going through its hole and round.
If you can do that for your general form and determine the
respective x, y and z for your new coordinates, then you
can use surf() to plot a parametric 2D surface in 3D space.
I did that for some tori. If you want, I can email you the
m-files.
Bastian Stahmer <bastian@beckspc.de> wrote in message
<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
I avoid doing homework problems in general, but
I will offer a suggestion. When you are trying to
eat an elephant, do it one bite at a time.
Break your problem into manageable chunks. I.e.,
can you determine when a surface is parabolic?
Elliptic? Hyperbolic? Write a small piece of code
that returns this information for any set of
coefficients.
Can you plot a unit sphere, centered at the origin?
How about one with different center and radius?
Are these just transformations of the unit sphere?
Next, write another small function that plots only
ellipsoids. Is this a simple transformation of the
sphere problem? Can you do this for the simple
case where the axes of the ellipse are the same
as the cartesian axes?
Next, figure out how to rotate the more general
problem to reduce it to one you already know
how to solve.
Repeat all of the same steps for parabolic and
hyperbolic surfaces.
When you are done with this, you might feel
comfortably stuffed, but the elephant will have
been consumed, and with less effort than you
thought.
"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:
On 2008-01-28 14:33:02 +0100, "John D'Errico"
<woodchips@rochester.rr.com> said:
> When you are trying to eat an elephant, do it one bite at a time.
Well, if you compare the size of an elephant to the amount you can bite
at a time, my problem would be a pretty huge one and would need much
more steps than you outlined :-)
Thanks for Ideas, I had something similar already in my mind but the
tool included in Mac OS X, Grapher, is able to handle such surfaces. So
I think there has to be an easier solution (Like the one Steve Lord
sketched in the next follow-up).
> When you are done with this, you might feel
> comfortably stuffed, but the elephant will have
> been consumed, and with less effort than you
> thought.
If Steve's solutions doesn't work for me I'll grab a napkin and get
some ketchup...
On 2008-01-28 17:02:49 +0100, "Steven Lord" <slord@mathworks.com> said:
> 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, thanks for your Ideas, I'll try them out tomorrow.
Bastian Stahmer <bastian@beckspc.de> wrote in message
<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:
>
> 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.
>
> Thank you,
>
> Bastian.
>
> [1] http://www.cs.mtu.edu/~shene/COURSES/cs3621/NOTES/geometry/
simple.html
----------
You can simplify matters if you find the following eigenvectors and
eigenvalues:
[v,s] = eig([A,D,E;D,B,F;E,F,C];
In general, this and completing the squares will allow you to make a
transformation determined by v to new cartesian coordinates x,y,z which
satisfies
a*x^2+b*y^2+c*z^2 = 1
if all the eigenvalues are nonzero. Depending on the number of negative
quantities in a, b, and c, this is either an ellipsoid, a one-sheeted
hyperboloid, or a two-sheeted hyperboloid. In case one of the eigenvalues is
zero, you get either an elliptical, or a hyperbolic, paraboloid. In each of these
cases it should be relatively easy for you to define two parameters which are
capable of generating the surface, in the manner mentioned by Ingo. Of
course there are various degenerate forms possible in these cases, but doing
an eigenvector analysis is the key to understanding these quadratic surfaces.
Roger Stafford
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.