Orientation of ellipsoid

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.

 Accepted Answer

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 Comments

Sakshi
Sakshi on 14 Jun 2011
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 on 14 Jun 2011
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 on 14 Jun 2011
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 ?
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 on 15 Jun 2011
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.
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 on 15 Jun 2011
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.
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.
If I have answered your original question, please close this question out by accepting the answer (click the appropriate button). Thanks.
Sakshi
Sakshi on 15 Jun 2011
Thank you for your time and patience.
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?

Sign in to comment.

More Answers (1)

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

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products

Asked:

on 13 Jun 2011

Commented:

on 18 Dec 2020

Community Treasure Hunt

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

Start Hunting!