Re: rookie Q, visualize function with 3 variables
- From: "Roger Stafford" <ellieandrogerxyzzy@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 22 Nov 2007 07:48:06 +0000 (UTC)
"Bo Pan" <ppyzbp@xxxxxxxxxxxxxxxx> wrote in message <fi2n2a$1nt
$1@xxxxxxxxxxxxxxxxxx>...
hi--------
i've got a function in the form of
x^2 + 6xy - 2y^2 - 2yz + z^2 = 24
how can i visualize this function in matlab?
thanks
Perhaps it would help in visualizing this to know that the surface defined by
your equation is that of a one-sheeted hyperboloid. However its principal
axes are not aligned with your x,y,z coordinate axes. You can determine
what these principal axes are as follows.
From the coefficients in the quadratic expression define the matrix
e = [ 1 , 6/2 , 0/2;
6/2 , -2 , -2/2;
0/2 , -2/2 , 1 ];
That is, the coefficients of x^2, y^2, and z^2 are its diagonal elements and
half those of x*y, y*z, and x*z (which isn’t there in this case) are its
symmetrical off-diagonals.
Then find the eigenvectors and eigenvalues of e.
[v,d] = eig(e);
v =
0.80178372573727 -0.31622776601684 0.50709255283711
0.53452248382485 -0.00000000000000 -0.84515425472852
-0.26726124191242 -0.94868329805051 -0.16903085094570
diag(d) =
3.00000000000000
1.00000000000000
-4.00000000000000
The columns of v are the eigenvectors and they constitute the three principal
directions of the hyperboloid. The diagonals of d are the eigenvalues (and in
this case are all integers.)
You then define a transformed (rotated) coordinate system (X,Y,Z) in terms
of these eigenvectors.
X = v(1,1)*x+v(2,1)*y+v(3,1)*z;
Y = v(1,2)*x+v(2,2)*y+v(3,2)*z;
Z = v(1,3)*x+v(2,3)*y+v(3,3)*z;
The X, Y, and Z axes point in the direction of the hyperboloid’s principal axes
and we have the identity
d(1,1)*X^2+d(2,2)*Y^2+d(3,3)*Z^2 =
3*X^2+1*Y^2+(-4)*Z^2 =
x^2+6*x*y-2*y^2-2*y*z+z^2 = 24
or
X^2/8 + Y^2/24 - Z^2/6 = 1
This makes it evident that we are dealing with a one-sheeted hyperboloid
with the above principal directions. Every cross section orthogonal to the Z
axis - that is, having a constant value of Z - will be an X,Y ellipse:
X^2/8 + Y^2/24 = 1 + Z^2/6
Similarly, every cross section containing the Z-axis will be a hyperbola.
Presumably you can now use the new transformed X,Y,Z coordinates to
generate a surface which matlab can display using a function like 'surf'.
Roger Stafford
.
- Follow-Ups:
- Re: rookie Q, visualize function with 3 variables
- From: Roger Stafford
- Re: rookie Q, visualize function with 3 variables
- References:
- rookie Q, visualize function with 3 variables
- From: Bo Pan
- rookie Q, visualize function with 3 variables
- Prev by Date: Re: How to use a Nueral Network object in C or C++
- Next by Date: how to save multifile one by one?
- Previous by thread: rookie Q, visualize function with 3 variables
- Next by thread: Re: rookie Q, visualize function with 3 variables
- Index(es):
Loading