Thread Subject: rotation of ellipsoids

Subject: rotation of ellipsoids

From: thomas

Date: 4 Mar, 2009 19:44:02

Message: 1 of 9

I have created a plot with two ellipsoids in it, i now need to get them to rotate, does anyone know of any sources that may help me to implement this?

AU=1.5;
 q=(0:0.0001:2)*pi;
 
 eE=0.4; %eccentricity
 aE=1*AU; %semi-major axis (horizontal radius)
 bE=aE*0.9165; %semi-minor axis (vertical radius)
  
 xe=(aE*cos(q));
 ye=(bE*sin(q) + 2);

 f=figure(1);
 plot(xe,ye);
 axis([-2.5*AU 2.5*AU -2.5*AU 2.5*AU]);
 
 hold on
 
 eE=0.4; %eccentricity
 aE=1*AU; %semi-major axis (horizontal radius)
 bE=aE*0.9165; %semi-minor axis (vertical radius)
 Ypos = bE*(1-eE);
 
 xe1=(aE*cos(q));
 ye1=(bE*sin(q) - 2);

 f=figure(1);
 plot(xe1,ye1);
 axis([-2.5*AU 2.5*AU -2.5*AU 2.5*AU]);

cheers tom

Subject: rotation of ellipsoids

From: us

Date: 4 Mar, 2009 20:20:19

Message: 2 of 9

"thomas"
> I have created a plot with two ellipsoids in it, i now need to get them to rotate...

what - exactly - do you mean by ROTATE...
us

Subject: rotation of ellipsoids

From: Matt

Date: 4 Mar, 2009 22:24:01

Message: 3 of 9

"thomas " <bananabarmer@hotmail.co.uk> wrote in message <gomlm2$a3j$1@fred.mathworks.com>...
> I have created a plot with two ellipsoids in it, i now need to get them to rotate, does anyone know of any sources that may help me to implement this?
>
> AU=1.5;
> q=(0:0.0001:2)*pi;
>
> eE=0.4; %eccentricity
> aE=1*AU; %semi-major axis (horizontal radius)
> bE=aE*0.9165; %semi-minor axis (vertical radius)
>
> xe=(aE*cos(q));
> ye=(bE*sin(q) + 2);

xrotated=cos(theta)*xe+sin(theta)*ye;
yrotated=-sin(theta)*xe+cos(theta)*ye;

Subject: rotation of ellipsoids

From: Roger Stafford

Date: 5 Mar, 2009 04:42:01

Message: 4 of 9

"thomas " <bananabarmer@hotmail.co.uk> wrote in message <gomlm2$a3j$1@fred.mathworks.com>...
> I have created a plot with two ellipsoids in it, i now need to get them to rotate, does anyone know of any sources that may help me to implement this?
> ........

  You haven't yet answered Urs's question: "what - exactly - do you mean by ROTATE"? What axes do you wish to rotate your two half-ellipses about? As they stand they are not yet ellipsoids. The only way you can make them into ellipsoids is to rotate them 2*pi radians about their respective major axes, but that would take you into the third dimension containing x, y, and z axes where you cannot make much use of the two-dimensional 'plot' function. You very much need to clarify what it is you wish to do, Thomas.

Roger Stafford

Subject: rotation of ellipsoids

From: thomas

Date: 5 Mar, 2009 11:26:06

Message: 5 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gonl6o$78u$1@fred.mathworks.com>...
> "thomas " <bananabarmer@hotmail.co.uk> wrote in message <gomlm2$a3j$1@fred.mathworks.com>...
> > I have created a plot with two ellipsoids in it, i now need to get them to rotate, does anyone know of any sources that may help me to implement this?
> > ........
>
> You haven't yet answered Urs's question: "what - exactly - do you mean by ROTATE"? What axes do you wish to rotate your two half-ellipses about? As they stand they are not yet ellipsoids. The only way you can make them into ellipsoids is to rotate them 2*pi radians about their respective major axes, but that would take you into the third dimension containing x, y, and z axes where you cannot make much use of the two-dimensional 'plot' function. You very much need to clarify what it is you wish to do, Thomas.
>
> Roger Stafford

sorry i wish to rotate them 360 degrees clockwise around their centers so that i can compare the distance between them as they rotate.

Subject: rotation of ellipsoids

From: us

Date: 5 Mar, 2009 12:06:03

Message: 6 of 9

"thomas"
> sorry i wish to rotate them 360 degrees clockwise around their centers so that i can compare the distance between them as they rotate...

one of the solutions

% the data
     xc=3; % <- x center of ellipse
     yc=3; % <- y center
     ma=2; % <- major
     mb=1; % <- minor
     ar=2; % <- resolution [deg]
     th=360:-10:0; % <- your rotation angles [deg]
% the engine
% - compute ellipse parameters
     ang=0:ar:360;
     cc=ma*cosd(ang); % <- note: SIND/COSD!
     sc=mb*sind(ang);
% the plot
     figure;
     set(gca,'xlim',[0,6],'ylim',[0,6]);
     lh=nan;
for cth=th(:).'
% - current tilt
     ct=cosd(cth);
     st=sind(cth);
% - current ellipse
     x=xc+cc*ct-sc*st;
     y=yc+cc*st+sc*ct;
if ishandle(lh)
     delete(lh);
end
     lh=line(x,y);
     title(sprintf('angle %g',cth));
     pause(.25);
end

us

Subject: rotation of ellipsoids

From: thomas

Date: 5 Mar, 2009 15:14:02

Message: 7 of 9

"us " <us@neurol.unizh.ch> wrote in message <goof7b$49r$1@fred.mathworks.com>...
> "thomas"
> > sorry i wish to rotate them 360 degrees clockwise around their centers so that i can compare the distance between them as they rotate...
>
> one of the solutions
>
> % the data
> xc=3; % <- x center of ellipse
> yc=3; % <- y center
> ma=2; % <- major
> mb=1; % <- minor
> ar=2; % <- resolution [deg]
> th=360:-10:0; % <- your rotation angles [deg]
> % the engine
> % - compute ellipse parameters
> ang=0:ar:360;
> cc=ma*cosd(ang); % <- note: SIND/COSD!
> sc=mb*sind(ang);
> % the plot
> figure;
> set(gca,'xlim',[0,6],'ylim',[0,6]);
> lh=nan;
> for cth=th(:).'
> % - current tilt
> ct=cosd(cth);
> st=sind(cth);
> % - current ellipse
> x=xc+cc*ct-sc*st;
> y=yc+cc*st+sc*ct;
> if ishandle(lh)
> delete(lh);
> end
> lh=line(x,y);
> title(sprintf('angle %g',cth));
> pause(.25);
> end
>
> us
thank you very much this is a great help to me

regards tom

Subject: rotation of ellipsoids

From: Josef

Date: 17 Dec, 2009 12:16:06

Message: 8 of 9

"thomas " <bananabarmer@hotmail.co.uk> wrote in message <gooq7q$mvm$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <goof7b$49r$1@fred.mathworks.com>...
> > "thomas"
> > > sorry i wish to rotate them 360 degrees clockwise around their centers so that i can compare the distance between them as they rotate...
> >
> > one of the solutions
> >
> > % the data
> > xc=3; % <- x center of ellipse
> > yc=3; % <- y center
> > ma=2; % <- major
> > mb=1; % <- minor
> > ar=2; % <- resolution [deg]
> > th=360:-10:0; % <- your rotation angles [deg]
> > % the engine
> > % - compute ellipse parameters
> > ang=0:ar:360;
> > cc=ma*cosd(ang); % <- note: SIND/COSD!
> > sc=mb*sind(ang);
> > % the plot
> > figure;
> > set(gca,'xlim',[0,6],'ylim',[0,6]);
> > lh=nan;
> > for cth=th(:).'
> > % - current tilt
> > ct=cosd(cth);
> > st=sind(cth);
> > % - current ellipse
> > x=xc+cc*ct-sc*st;
> > y=yc+cc*st+sc*ct;
> > if ishandle(lh)
> > delete(lh);
> > end
> > lh=line(x,y);
> > title(sprintf('angle %g',cth));
> > pause(.25);
> > end
> >
> > us
> thank you very much this is a great help to me
>
> regards tom

Hi all,

I counter the problems how to transform ellipsoid.
I know the parametric equations:

data=zeros(20,20,20);
a=4;
b=2;
c=2;
phi=-90:90;
theta=-180:180;
X=a*cos(phi)*cos(theta)
Y=b*cos(phi)*sin(theta)
Z=c*sin(phi)
[x,y,z]=meshgrid(1:20,1:20,1:20);
    indexy=find((((xx-10).^2/(a*a))+(yy-10).^2/(b*b)+(zz-10).^2/(c*c))<=1);
    
    data(indexy)=1;

Does anybody know how to transform the ellipsoid to enale its rotation given by e.g, angle theta?

When making rotating ellipse I use:
.....
 X = cos(phi)*x - sin(phi)*y;
 Y = sin(phi)*x + cos(phi)*y;
 indexy=find(( X.^2/a.^2+Y.^2/b.^2)<=1);
.....
Thank you,

 Josef

Subject: rotation of ellipsoids

From: Josef

Date: 17 Dec, 2009 12:19:04

Message: 9 of 9

"thomas " <bananabarmer@hotmail.co.uk> wrote in message <gooq7q$mvm$1@fred.mathworks.com>...
> "us " <us@neurol.unizh.ch> wrote in message <goof7b$49r$1@fred.mathworks.com>...
> > "thomas"
> > > sorry i wish to rotate them 360 degrees clockwise around their centers so that i can compare the distance between them as they rotate...
> >
> > one of the solutions
> >
> > % the data
> > xc=3; % <- x center of ellipse
> > yc=3; % <- y center
> > ma=2; % <- major
> > mb=1; % <- minor
> > ar=2; % <- resolution [deg]
> > th=360:-10:0; % <- your rotation angles [deg]
> > % the engine
> > % - compute ellipse parameters
> > ang=0:ar:360;
> > cc=ma*cosd(ang); % <- note: SIND/COSD!
> > sc=mb*sind(ang);
> > % the plot
> > figure;
> > set(gca,'xlim',[0,6],'ylim',[0,6]);
> > lh=nan;
> > for cth=th(:).'
> > % - current tilt
> > ct=cosd(cth);
> > st=sind(cth);
> > % - current ellipse
> > x=xc+cc*ct-sc*st;
> > y=yc+cc*st+sc*ct;
> > if ishandle(lh)
> > delete(lh);
> > end
> > lh=line(x,y);
> > title(sprintf('angle %g',cth));
> > pause(.25);
> > end
> >
> > us
> thank you very much this is a great help to me
>
> regards tom

Hi all,

I counter the problems how to transform ellipsoid.
I know the parametric equations:

data=zeros(20,20,20);
a=4;
b=2;
c=2;
phi=-90:90;
theta=-180:180;
X=a*cos(phi)*cos(theta)
Y=b*cos(phi)*sin(theta)
Z=c*sin(phi)
[x,y,z]=meshgrid(1:20,1:20,1:20);
    indexy=find((((xx-10).^2/(a*a))+(yy-10).^2/(b*b)+(zz-10).^2/(c*c))<=1);
    
    data(indexy)=1;

Does anybody know how to transform the ellipsoid to enale its rotation given by e.g, angle theta?

When making rotating ellipse I use:
.....
 X = cos(phi)*x - sin(phi)*y;
 Y = sin(phi)*x + cos(phi)*y;
 indexy=find(( X.^2/a.^2+Y.^2/b.^2)<=1);
.....
Thank you,

 Josef

Tags for this Thread

Everyone's Tags:

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.

Tag Activity for This Thread
Tag Applied By Date/Time
ellipse us 5 Mar, 2009 07:10:04
code us 5 Mar, 2009 07:10:04
sind us 5 Mar, 2009 07:10:04
line us 5 Mar, 2009 07:10:04
cosd us 5 Mar, 2009 07:10:04
ellipse thomas 4 Mar, 2009 14:45:11
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