How to create an Object insertable in a 3D plot?

I would like to create three or four objects, made up of a number of individual points, that at my command can be inserted into a 3D plot, at the position and orientation I want to. How can this be done?
Essentially, I have a 3D Plot. I made other 3D plots, and would like to input some of those plots as objects into the new 3D plot. Its like grouping objects in Word i suppose. Through commands, is it possible to dictate orientation and position of that group.

4 件のコメント

José-Luis
José-Luis 2017 年 8 月 15 日
Can't you just plot all of them in the same place?
If you want to manipulate them, you'll need to manipulate the underlying data and plot again.
Marco Froelich
Marco Froelich 2017 年 8 月 15 日
It would be easier if you had that object, and could input in where ever I want. Its a pretty complex object. And can you explain that?
José-Luis
José-Luis 2017 年 8 月 15 日
What I mean there is no (easy, or sane) way you can have multiple 3D objects in one plot and manipulate them individually.
Also, I don't think the functionality is there to apply the transforms you seem want to an existing object: you will need to transform the underlying data.
Marco Froelich
Marco Froelich 2017 年 8 月 16 日
Yes thats what I mean tho. As in control the position and orientation of the objects from code.

サインインしてコメントする。

回答 (1 件)

Sky Sartorius
Sky Sartorius 2017 年 8 月 17 日

0 投票

One approach could be to leverage the plotted object's XData, YData, and ZData, homogeneous coordinates, and the makehgtform function:
h = surf(peaks);
[X,Y] = meshgrid(h.XData,h.YData);
Z = h.ZData;
sz = size(Z);
M = [X(:) Y(:) Z(:) ones(numel(Z),1)]';
t = makehgtform('axisrotate',[1,2,3],pi/4,'translate',[2,10,-50]);
% Orient and position your object where you want it.
Mt = t*M;
h.XData = reshape(Mt(1,:),sz);
h.YData = reshape(Mt(2,:),sz);
h.ZData = reshape(Mt(3,:),sz);

2 件のコメント

Marco Froelich
Marco Froelich 2017 年 8 月 18 日
Could you elaborate on this? I dont fully understand what this helps you acheive :) is it taking the x,y,z data from a table of results?
José-Luis
José-Luis 2017 年 8 月 18 日
The x, y, z data are stored in the figure. Sky is accessing them and changing them, which is what I had suggested in my original comment. You'd need to do that for each individual object.
I did not know makehgtform() existed.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

タグ

質問済み:

2017 年 8 月 15 日

コメント済み:

2017 年 8 月 18 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by