Path: news.mathworks.com!not-for-mail
From: "Alexander" <alexander.erlich@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Combine several matrices for surf plotting
Date: Tue, 28 Apr 2009 18:04:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 20
Message-ID: <gt7geh$ogk$1@fred.mathworks.com>
Reply-To: "Alexander" <alexander.erlich@gmail.com>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1240941841 25108 172.30.248.37 (28 Apr 2009 18:04:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 28 Apr 2009 18:04:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1217178
Xref: news.mathworks.com comp.soft-sys.matlab:536001


Hi, 

let's say I have two different objects: the first one is a cylinder created with the cylinder command. Its x-y-z matrices are X1, Y1, Z1

The second one is a torus with the matrices X2, Y2, Z2, created with loops like this (just for demonstration - the loops actually do not matter now):

X2 = cos(phi) ;
Y2 = sin(phi) ;
Z2 = r * sin(phi) * ones(size(theta)) ;

I can plot each of them with surf(Xi, Yi, Zi). But I would like to plot both of them in one plot. How could I do that?

Suppose I had a combined matrices Xc, Yc, Zc. Then surf(Xc, Yc, Zc) would give me a picture of both the torus and the cylinder. Now, if I wanted to e.g. change the position or rotation of one of the object, let's say the cylinder, I would just change the approporiate coordinates within the Xc, Yc, and Zc matrices. Naturally, I would leave those coordinates which concern the torus untouched. 

Just if you're interested why I'm asking this:
I would like to create a simulation of a spinning top (for simplicity, it might be won from the cylinder command) with its Cardan suspension frames (they are half-torus like). Now, the suspension moves differently from the top which it holds. I might have the big matrices Xc, Yc, and Zc containing all the data about the top and every suspension frame. Then, I would (frame by frame) rotate the top and each frame individually. I'd do that by changing the appropriate parts of the Xc, Yc, Zc matrix. Then I would update the surf plot with the new matrices Xc, Yc, Zc. This would animate my spinning top. I finished the program for the mere top already, and now I would like to implement the Cardan suspension frames.

I'm looking forward to your replies!

Alexander