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 CenterFile Exchange에서 3-D Scene Control에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by