From: Ahmed Hussain on
I want to plot a 3D sphere in a figure which should be inside another 3D figure. It should be like that: If I 3D rotate the outer figure, the inner figure should also rotate likewise. But if I rotate in the inner figure it should have no effect on the inner figure. Is it possible?

To understand this problem more easily, imagine I want to draw a football inside a cupboard. If I move the cupboard the ball will also move likewise. But if I move the ball, the position of cupboard will not change.

Is it possible to do such a thing in matlab? If yes, please help!

Ahmed H.
CTH - Sweden
From: Saurabh Mahapatra on
Hi Ahmed,

One possible solution is using Simulink 3D Animation with MATLAB. You build your cupboard modeled as with three 2D planes and have the football modelled as a 3D sphere(with textures!) in VRML.

If you use the transform node with "nesting", so that football node is the child of the cupboard node, then any motion of the parent(cupboard) will result in motion of the child(football).

I use this concept in the wind farm video demo here:

http://www.mathworks.com/matlabcentral/fileexchange/26273-animate-a-wind-farm-with-matlab

The analogy is close-your "cupboard" is the hub of my turbine while the blades are the "footballs" in your problem. I want the blades to move when the hub rotates but not vice versa. Observe the nesting of the nodes in the problem.

Thanks,

Saurabh
From: Ahmed Hussain on
Hello,

Thank you so much! Your work is really excellent. I'm a student and my university have a demonstration version of Simulink 3D Animation which makes it difficult for me to use your approach.

I have the license for MATLAB toolboxes. If there is any other solution you can suggest kindly help!

Thank you,

Best Wishes,

Ahmed H.

"Saurabh Mahapatra" <saurabh.mahapatra(a)mathworks.com> wrote in message <hkv8io$92t$1(a)fred.mathworks.com>...
> Hi Ahmed,
>
> One possible solution is using Simulink 3D Animation with MATLAB. You build your cupboard modeled as with three 2D planes and have the football modelled as a 3D sphere(with textures!) in VRML.
>
> If you use the transform node with "nesting", so that football node is the child of the cupboard node, then any motion of the parent(cupboard) will result in motion of the child(football).
>
> I use this concept in the wind farm video demo here:
>
> http://www.mathworks.com/matlabcentral/fileexchange/26273-animate-a-wind-farm-with-matlab
>
> The analogy is close-your "cupboard" is the hub of my turbine while the blades are the "footballs" in your problem. I want the blades to move when the hub rotates but not vice versa. Observe the nesting of the nodes in the problem.
>
> Thanks,
>
> Saurabh
From: Husam Aldahiyat on
"Ahmed Hussain" <ahmedhussain85(a)yahoo.com> wrote in message <hkv6mq$88s$1(a)fred.mathworks.com>...
> I want to plot a 3D sphere in a figure which should be inside another 3D figure. It should be like that: If I 3D rotate the outer figure, the inner figure should also rotate likewise. But if I rotate in the inner figure it should have no effect on the inner figure. Is it possible?
>
> To understand this problem more easily, imagine I want to draw a football inside a cupboard. If I move the cupboard the ball will also move likewise. But if I move the ball, the position of cupboard will not change.
>
> Is it possible to do such a thing in matlab? If yes, please help!
>
> Ahmed H.
> CTH - Sweden

You have two axes, let's say they're called axes1 and axes2. axes1 contains one plot, and its "child" is axes2.

If you rotate axes1, what happens is you change the axes 'view' property (vector containing two elements; azumith and elevation), so what you want to do is that whenever the view property of the first axes changes, the second axes' view property is changed as well. Right?

You can do this using v = get(axes1,'view') and then set(axes2,'view',v).

In order for the program to do this automatically, you can assign to the first figure a buttondownfcn which keeps checking the new view valuesuntil you stop rotating (i.e. release the mouse button).

Hope this helps.
From: Steven Lord on

"Husam Aldahiyat" <numandina(a)gmail.com> wrote in message
news:hl0o06$d6d$1(a)fred.mathworks.com...
> "Ahmed Hussain" <ahmedhussain85(a)yahoo.com> wrote in message
> <hkv6mq$88s$1(a)fred.mathworks.com>...
>> I want to plot a 3D sphere in a figure which should be inside another 3D
>> figure. It should be like that: If I 3D rotate the outer figure, the
>> inner figure should also rotate likewise. But if I rotate in the inner
>> figure it should have no effect on the inner figure. Is it possible?
>>
>> To understand this problem more easily, imagine I want to draw a football
>> inside a cupboard. If I move the cupboard the ball will also move
>> likewise. But if I move the ball, the position of cupboard will not
>> change.
>>
>> Is it possible to do such a thing in matlab? If yes, please help!
>>
>> Ahmed H.
>> CTH - Sweden
>
> You have two axes, let's say they're called axes1 and axes2. axes1
> contains one plot, and its "child" is axes2.
>
> If you rotate axes1, what happens is you change the axes 'view' property
> (vector containing two elements; azumith and elevation), so what you want
> to do is that whenever the view property of the first axes changes, the
> second axes' view property is changed as well. Right?
>
> You can do this using v = get(axes1,'view') and then set(axes2,'view',v).
>
> In order for the program to do this automatically, you can assign to the
> first figure a buttondownfcn which keeps checking the new view valuesuntil
> you stop rotating (i.e. release the mouse button).

Another possibility is to use the ROTATE function. A slightly modified
version of the example from the reference page:

http://www.mathworks.com/access/helpdesk/help/techdoc/ref/rotate.html

h = surf(peaks(20));
zdir = [0 0 1];
center = [10 10 0];
for k = 1:90
rotate(h, zdir, 1, center);
drawnow
end

--
Steve Lord
slord(a)mathworks.com
comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ