how can i rotate many ellipsoids

2 ビュー (過去 30 日間)
imola
imola 2014 年 9 月 22 日
コメント済み: Geoff Hayes 2014 年 9 月 24 日
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 Center および File Exchange3-D Scene Control についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by