Hello, I am using ellipsoid function to represent an ellipsoid graphically. The input list requires me to enter the coordinates of the centre of ellipsoid and its semi-axes. There is no input for the orientation of the axis of the ellipsoid with respect to the coordinate system. Is there any way, this can be incorporated if my ellipsoids are at angle with respect to x, y and z axis.

 채택된 답변

Matt Fig
Matt Fig 2011년 6월 13일

2 개 추천

See the help for the ROTATE function.
For example:
[x, y, z] = ellipsoid(0,0,0,5.9,3.25,3.25,30);
S = surfl(x, y, z);
colormap copper
axis equal
xlabel('X')
ylabel('Y')
zlabel('Z')
pause % Push return to see the rotation take place.
rotate(S,[0 0 1],45)

댓글 수: 11

Sakshi
Sakshi 2011년 6월 14일
I used the rotate command but am getting the error " must contain child axes only" Could you please throw somelight on the meaning of this ? I used below commands:
[x,y,z]=ellipsoid(0,0,0,sx,sy,sz,meshSize);
phix_d=phix*180/pi();
axis([0 100 0 100 0 100])
dir=[1 0 0];
rotate(x,dir,phix_d)
Sakshi
Sakshi 2011년 6월 14일
Also I wanted to add-on that the purpose of my doing this rotation is not visually plot the ellipsoid. The purpose is to generate large number of rotated ellipsoids and use their coordinates for writing in .vtk file format.
Sakshi
Sakshi 2011년 6월 14일
I have now managed to carry out rotation but the command is carring out rotation only with respect to only one axis. I need to rotate by three different angles with respect to all three x, y and z by amount phix , phiy and phiz respectively. How should I do that ?
Matt Fig
Matt Fig 2011년 6월 14일
You need to read the documentation for the ROTATE function. This should always be your first step when confronted with a question like this.
doc rotate
Sakshi
Sakshi 2011년 6월 15일
I did read the documentation on Rotate but I still have not been able to rotate the ellipsoid by all three axis x, y and z by three different angles phix, phiy and phiz.
Matt Fig
Matt Fig 2011년 6월 15일
According to the documentation,
rotate(S,[1 0 0],45) % Rotate around the x axis 45 degrees.
rotate(S,[0 1 0],45) % Rotate around the y axis 45 degrees.
rotate(S,[0 0 1],45) % Rotate around the z axis 45 degrees.
You can do these sequentially...
Sakshi
Sakshi 2011년 6월 15일
thank you. One last question. After doing so, I was expecting the x,y and z coordinates to change after the rotation. This however did not happen. My purpose of rotating the ellipsoid was to get new set of coordinates and then write them in vtk file.
Matt Fig
Matt Fig 2011년 6월 15일
Of course they change.
>> plot_ellipse
>> Z = get(S,'zdata'); % Get the zdata before rotation.
>> rotate(S,[1 1 1],45);
>> Z2 = get(S,'zdata'); % Get the zdata after rotation.
>> isequal(Z,Z2)
ans =
0
Now you can do the same thing with xdata and ydata.
Matt Fig
Matt Fig 2011년 6월 15일
If I have answered your original question, please close this question out by accepting the answer (click the appropriate button). Thanks.
Sakshi
Sakshi 2011년 6월 15일
Thank you for your time and patience.
Amin Ataei
Amin Ataei 2020년 12월 18일
after rotation the ellipsoid , how can we check if a given point with its coordinante(x,y,z) is inside of ellipsoid.
If ellipsoid is oriented in main axes we can use the equation from ellipse also :
(x/a)2 + (y/b)2 + (z/c)2 < 1 point is inside ellipsoid
(x/a)2 + (y/b)2 + (z/c)2 > 1 point is not inside ellipsoid
but how can we check the point when ellipsoid is rotated? in this case are all point of ellipsoid rotated and we can not use upper equation anymore , right?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Harsha Vardhan Rao  Avunoori
Harsha Vardhan Rao Avunoori 2011년 6월 13일

0 개 추천

You can generate an ellipsoid with the ellipsoid function and while plotting you can use the rotate() suggest by Matt.It should help you.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

제품

질문:

2011년 6월 13일

댓글:

2020년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by