Thread Subject: Combine several matrices for surf plotting

Subject: Combine several matrices for surf plotting

From: Alexander

Date: 28 Apr, 2009 18:04:01

Message: 1 of 1

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

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.

rssFeed for this Thread
 

MATLAB Central Terms of Use

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 Terms prior to use.

Contact us at files@mathworks.com