how can i rotate many ellipsoids

2 次查看(过去 30 天)
imola
imola 2014-9-22
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

回答(1 个)

Geoff Hayes
Geoff Hayes 2014-9-22
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 个评论
Geoff Hayes
Geoff Hayes 2014-9-24
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Data Synthesis 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by