Message Boards Message Boards

0
|
3702 Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Syntax for rotated ellipsoid in Plot3D[ ]?

Posted 2 years ago

Hello.

Plot[{(3 x + Sqrt[x (16 - 7 x)])/4, (3 x - Sqrt[x (16 - 7 x)])/4}, {x,0, 2.5}]

is the syntax for a rotated ellipse in 2 D. But what is the syntax for a rotated ellipsoid in Plot3D. I know I can rotate the image, but I want to know the syntax. Many thanks.

POSTED BY: Robert Jenkins
5 Replies
Posted 2 years ago

Brill! Thank you very much.

POSTED BY: Robert Jenkins
Posted 2 years ago

Thank you for your reply. Unfortunately, I get a series of error messages with your script. One is: Tag In is protected. Another is: {rule} is neither a list of replacement rules nor a valid dispatch \ table, and so cannot be used for replacing. >> My version of Mathematica is 10. Could it be incompatible with yours?

POSTED BY: Updating Name
Posted 2 years ago

Try by commenting out the first line of Martijns code

enter image description here

And do the same with the last lines:

enter image description here

POSTED BY: Hans Milton

if your goal is to get the correct equation this code will generate it. However, plotting an ellipsoid can be accomplished much simpler.

In[]:= (*some parameters*)
rule = {a -> 0.2, b -> 1, c -> 2, rx -> 10. Degree, ry -> 15. Degree, 
   rz -> -30. Degree, tx -> -1, ty -> 1.5, tz -> 0.8};

(*3D equation for ellipsoid*)
eq = x^2/a + y^2/b + z^2/c == 1.;
(*apply rotation and translation to the x,y,z coordinates*)
rot = Thread[{x, y, 
     z} -> (RotationMatrix[rz, {0, 0, 1}] . 
      RotationMatrix[ry, {0, 1, 0}] . 
      RotationMatrix[rx, {1, 0, 0}] . ({x, y, z} - {tx, ty, tz}))];
(*equation for rotated and translated ellipsoid*)
eqRot = eq /. rot;

(*solve for z*)
eqPlot = z /. NSolve[eqRot, z];

(*fill in some numbers*)
plot = eqPlot /. rule
p1 = Plot3D[plot, {x, -3, 3}, {y, -3, 3}, 
   PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}}, BoxRatios -> 1, 
   ViewPoint -> Front];

(*using Ellipsoid*)
ellipsoid = 
  Translate[
   Rotate[Rotate[
     Rotate[Ellipsoid[{0, 0, 0}, DiagonalMatrix[{a, b, c}]], -rx, {1, 
       0, 0}], -ry, {0, 1, 0}], -rz, {0, 0, 1}], {tx, ty, tz}];
p2 = Graphics3D[(ellipsoid) /. rule, 
   PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}}, BoxRatios -> 1, 
   Axes -> True, ViewPoint -> Front];

GraphicsRow[{p1, p2, Show[p1, p2]}]

Out[]= {0.807372 (0.462989 - 1.14238 x - 0.409664 y - 
    1. Sqrt[(-0.462989 + 1.14238 x + 0.409664 y)^2 - 
      2.47717 (2.10003 + 1.21852 x + 3.76554 x^2 - 3.0741 y + 
         3.59912 x y + 2.11516 y^2)]), 
 0.807372 (0.462989 - 1.14238 x - 0.409664 y + 
    Sqrt[(-0.462989 + 1.14238 x + 0.409664 y)^2 - 
     2.47717 (2.10003 + 1.21852 x + 3.76554 x^2 - 3.0741 y + 
        3.59912 x y + 2.11516 y^2)])}
POSTED BY: Martijn Froeling
Posted 2 years ago

Another option is to use Ellipsoid.

RegionPlot3D[Ellipsoid[{0, 0, 0}, {{4, 3, 3}, {2, 3, 1}, {1, 2, 4}}]]

enter image description here

POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract