Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How to define the orientation of the cylinder?

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 04:28:04

Message: 1 of 9

Hello,

I'm using spherical coordinate system to define the orientation of the cyllinder - there is the azimuth and inclination angles, and the radius. So, the radius corresponds to the length of the cyllinder, while the azimuth and inclination angles correspond to its orientation. I also know the origin point of the cyllinder.

The question is how can I define the orientation of the cyllinder in MATLAB using the inclination and azimuth angles? Well, if someone has another ideas, then please let me know as well.

Currently, I can only define the length and radius of the cylinder as follows:
    cylinder_radius = 1;
    [X,Y,Z] = cylinder(cylinder_radius);
    Z=spherical_radius(i,1)*Z; % corresponds to the cylinder's length
    hs1 = surf(X,Y,Z);
    set(hs1, 'FaceColor','cyan');
    xlabel('x'); ylabel('y'); zlabel('z');
    view(30,30);

Thanks a lot for any idea!

Subject: How to define the orientation of the cylinder?

From: Rune Allnor

Date: 5 Apr, 2011 04:35:20

Message: 2 of 9

On Apr 5, 6:28 am, "Liana " <liananapalk...@email.arizona.edu> wrote:
> Hello,
>
> I'm using spherical coordinate system to define the orientation of the cyllinder - there is the azimuth and inclination angles, and the radius. So, the radius corresponds to the length of the cyllinder, while the azimuth and inclination angles correspond to its orientation. I also know the origin point of the cyllinder.
>
> The question is how can I define the orientation of the cyllinder in MATLAB

You don't need to. You already have all the required definitions,
be it 'in matlab' or elsewhere.

Rune

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 04:54:04

Message: 3 of 9

Thank you, Rune. Yes, I have all the parameters to define the orientation of the cyllinder. But I don't know the MATLAB bult-in function. Should I use 'rotate' or anything else?

Rune Allnor <allnor@tele.ntnu.no> wrote in message <6baef402-13bf-466e-982b-794f049d0bc9@z31g2000vbs.googlegroups.com>...
> On Apr 5, 6:28 am, "Liana " <liananapalk...@email.arizona.edu> wrote:
> > Hello,
> >
> > I'm using spherical coordinate system to define the orientation of the cyllinder - there is the azimuth and inclination angles, and the radius. So, the radius corresponds to the length of the cyllinder, while the azimuth and inclination angles correspond to its orientation. I also know the origin point of the cyllinder.
> >
> > The question is how can I define the orientation of the cyllinder in MATLAB
>
> You don't need to. You already have all the required definitions,
> be it 'in matlab' or elsewhere.
>
> Rune

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 06:16:05

Message: 4 of 9

Let me specify the question a little bit more. I need to plot (vizualise) the cyllinder using all the parameters that I have (azimuth and inclination angles, cylinder length and radius). I made some experiments,e.g.
a = [1 0 1]; % rotation around x-axis and z-axis
rotate(hs1,a,25); % rotation by 25 degrees
But the result is incorrect, of course. So, how can I define azimuth and inclination angles (let's say 60 and 25 degrees)?

"Liana" wrote in message <ine79c$e2g$1@fred.mathworks.com>...
> Thank you, Rune. Yes, I have all the parameters to define the orientation of the cyllinder. But I don't know the MATLAB bult-in function. Should I use 'rotate' or anything else?
>
> Rune Allnor <allnor@tele.ntnu.no> wrote in message <6baef402-13bf-466e-982b-794f049d0bc9@z31g2000vbs.googlegroups.com>...
> > On Apr 5, 6:28 am, "Liana " <liananapalk...@email.arizona.edu> wrote:
> > > Hello,
> > >
> > > I'm using spherical coordinate system to define the orientation of the cyllinder - there is the azimuth and inclination angles, and the radius. So, the radius corresponds to the length of the cyllinder, while the azimuth and inclination angles correspond to its orientation. I also know the origin point of the cyllinder.
> > >
> > > The question is how can I define the orientation of the cyllinder in MATLAB
> >
> > You don't need to. You already have all the required definitions,
> > be it 'in matlab' or elsewhere.
> >
> > Rune

Subject: How to define the orientation of the cylinder?

From: Matt J

Date: 5 Apr, 2011 14:28:05

Message: 5 of 9

"Liana" wrote in message <inec35$3oj$1@fred.mathworks.com>...
> Let me specify the question a little bit more. I need to plot (vizualise) the cyllinder using all the parameters that I have (azimuth and inclination angles, cylinder length and radius). I made some experiments,e.g.
> a = [1 0 1]; % rotation around x-axis and z-axis
> rotate(hs1,a,25); % rotation by 25 degrees
> But the result is incorrect, of course. So, how can I define azimuth and inclination angles (let's say 60 and 25 degrees)?
================

You have to take the xyz coordinates given by CYLINDER and transform them using an appropriate rotation matrix. The following is an example of this using my AxelRot tool

http://www.mathworks.com/matlabcentral/fileexchange/30864-3d-rotation-about-shifted-axis


theta=60; %aximuthal rotation in degrees.
inclin=25; %inclination angle in degrees

R_az= [cosd(theta),-sind(theta),0 ; ...
    sind(theta),cosd(theta),0 ;...
    0 0 1];


R_inclin=AxelRot(inclin, R_az(:,1),'R');

R=R_inclin * R_az; %compose the rotations

[X,Y,Z]=cylinder;

XYZ=R*[X(:).'; Y(:).' ; Z(:).']; %Apply rotation
X=reshape( XYZ(1,:), size(X));
Y=reshape( XYZ(2,:), size(Y));
Z=reshape( XYZ(3,:), size(Z));



surf(X,Y,Z)

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 19:27:04

Message: 6 of 9

Thank you, Matt! This is exactly what I've been searching for.

"Matt J" wrote in message <inf8tl$9cq$1@fred.mathworks.com>...
> "Liana" wrote in message <inec35$3oj$1@fred.mathworks.com>...
> > Let me specify the question a little bit more. I need to plot (vizualise) the cyllinder using all the parameters that I have (azimuth and inclination angles, cylinder length and radius). I made some experiments,e.g.
> > a = [1 0 1]; % rotation around x-axis and z-axis
> > rotate(hs1,a,25); % rotation by 25 degrees
> > But the result is incorrect, of course. So, how can I define azimuth and inclination angles (let's say 60 and 25 degrees)?
> ================
>
> You have to take the xyz coordinates given by CYLINDER and transform them using an appropriate rotation matrix. The following is an example of this using my AxelRot tool
>
> http://www.mathworks.com/matlabcentral/fileexchange/30864-3d-rotation-about-shifted-axis
>
>
> theta=60; %aximuthal rotation in degrees.
> inclin=25; %inclination angle in degrees
>
> R_az= [cosd(theta),-sind(theta),0 ; ...
> sind(theta),cosd(theta),0 ;...
> 0 0 1];
>
>
> R_inclin=AxelRot(inclin, R_az(:,1),'R');
>
> R=R_inclin * R_az; %compose the rotations
>
> [X,Y,Z]=cylinder;
>
> XYZ=R*[X(:).'; Y(:).' ; Z(:).']; %Apply rotation
> X=reshape( XYZ(1,:), size(X));
> Y=reshape( XYZ(2,:), size(Y));
> Z=reshape( XYZ(3,:), size(Z));
>
>
>
> surf(X,Y,Z)

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 20:43:07

Message: 7 of 9

Matt, I have one more question. How can I change the origin position of the cylinder from [0 0 0] to e.g. [25 0 25] (xyz). Thanks.

"Liana" wrote in message <infqe8$mfu$1@fred.mathworks.com>...
> Thank you, Matt! This is exactly what I've been searching for.
>
> "Matt J" wrote in message <inf8tl$9cq$1@fred.mathworks.com>...
> > "Liana" wrote in message <inec35$3oj$1@fred.mathworks.com>...
> > > Let me specify the question a little bit more. I need to plot (vizualise) the cyllinder using all the parameters that I have (azimuth and inclination angles, cylinder length and radius). I made some experiments,e.g.
> > > a = [1 0 1]; % rotation around x-axis and z-axis
> > > rotate(hs1,a,25); % rotation by 25 degrees
> > > But the result is incorrect, of course. So, how can I define azimuth and inclination angles (let's say 60 and 25 degrees)?
> > ================
> >
> > You have to take the xyz coordinates given by CYLINDER and transform them using an appropriate rotation matrix. The following is an example of this using my AxelRot tool
> >
> > http://www.mathworks.com/matlabcentral/fileexchange/30864-3d-rotation-about-shifted-axis
> >
> >
> > theta=60; %aximuthal rotation in degrees.
> > inclin=25; %inclination angle in degrees
> >
> > R_az= [cosd(theta),-sind(theta),0 ; ...
> > sind(theta),cosd(theta),0 ;...
> > 0 0 1];
> >
> >
> > R_inclin=AxelRot(inclin, R_az(:,1),'R');
> >
> > R=R_inclin * R_az; %compose the rotations
> >
> > [X,Y,Z]=cylinder;
> >
> > XYZ=R*[X(:).'; Y(:).' ; Z(:).']; %Apply rotation
> > X=reshape( XYZ(1,:), size(X));
> > Y=reshape( XYZ(2,:), size(Y));
> > Z=reshape( XYZ(3,:), size(Z));
> >
> >
> >
> > surf(X,Y,Z)

Subject: How to define the orientation of the cylinder?

From: Matt J

Date: 5 Apr, 2011 20:59:06

Message: 8 of 9

"Liana" wrote in message <infusr$bmf$1@fred.mathworks.com>...
> Matt, I have one more question. How can I change the origin position of the cylinder from [0 0 0] to e.g. [25 0 25] (xyz). Thanks.
>


Use BSXFUN to translate all the XYZ coordinates by [25 0 25]

Subject: How to define the orientation of the cylinder?

From: Liana

Date: 5 Apr, 2011 21:20:05

Message: 9 of 9

Thanks, Matt.

"Matt J" wrote in message <infvqq$quc$1@fred.mathworks.com>...
> "Liana" wrote in message <infusr$bmf$1@fred.mathworks.com>...
> > Matt, I have one more question. How can I change the origin position of the cylinder from [0 0 0] to e.g. [25 0 25] (xyz). Thanks.
> >
>
>
> Use BSXFUN to translate all the XYZ coordinates by [25 0 25]

Tags for this Thread

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.

Contact us