how can i rotate many ellipsoids

5 views (last 30 days)
imola
imola on 22 Sep 2014
Commented: Geoff Hayes on 24 Sep 2014
Dear all,
I try to use the program in next link to generate rotate many ellipsoids, I successfully generated them, but I find it confusing to rotate them.
http://www.mathworks.com/matlabcentral/fileexchange/24484-geom3d/content/geom3d/geom3d/drawEllipsoid.m
could anybody help me with it please Regards

Answers (1)

Geoff Hayes
Geoff Hayes on 22 Sep 2014
Imola - the drawEllipsoid function accepts a input vector of nine elements. The first three correspond to the centre of the ellipse (x,y,z), the second three correspond to the half-lengths of the ellipsoid axes (along x, y, and z), and the final three inputs correspond to the angle of orientation for the ellipsoid (relative to x-, y-, and z-axes).
Consider the following example where we rotate the ellipse counter-clockwise around the x-axis in five degree increments. The view command is set so that we view the xy plane only (as if looking down on the ellipse).
figure;
drawEllipsoid([10 20 30 50 30 10 0 0 0]);
view(0,90); % view xy plane
axis([-100 100 -100 100]);
hold on;
for k=5:5:360
cla;
drawEllipsoid([10 20 30 50 30 10 k 0 0],'drawEllipses',true); % note the k here
pause(1.0);
end
The drawEllipses parameter to the drawEllipsoid function draws an ellipse in the xy, xz, and yz planes which may help you visualize the ellipsoid better. Note that if you do this, then you must run the hold on command (as shown in the above example).
If you wish to rotate your ellipsoid relative to the y- and z-axes, then just manipulate the third set of three elements (to drawEllipsoid) in a similar fashion to that done for the x-axis.
  1 Comment
Geoff Hayes
Geoff Hayes on 24 Sep 2014
Imola - look at how you have defined the local variable elli as
elli = [10 20 30 50 30 10 0 0 0];
and then how you try to use it again as a function at
elli([10 20 30 50 30 10 k 0 0],'drawEllipses',true);
which generates the error Subscript indices must either be real positive integers or logicals. These two lines of code should call the drawEllipsoid function
drawEllipsoid([10 20 30 50 30 10 0 0 0]);
and
drawEllipsoid([10 20 30 50 30 10 k 0 0],'drawEllipses',true);
Replace the lines and observe results.

Sign in to comment.

Categories

Find more on 3-D Scene Control in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!