2
$\begingroup$

I need to plot a figure combining of a three-dimensional ellipsoid and its projections on the sides of a box. I have no idea about it. I need to have something like

enter image description here

in Mathematica. Thanks.

$\endgroup$
  • 1
    $\begingroup$ This, this, and this. $\endgroup$ – corey979 May 24 '18 at 6:30
  • $\begingroup$ It would be a pleasure if you provide a code for the case of an ellipsoid. $\endgroup$ – AYBRXQD May 24 '18 at 6:44
6
$\begingroup$
pp3d = ParametricPlot3D[{2 Cos[u] Sin[v], Sin[u] Sin[v], Cos[v]}, {v, 0, π}, {u, 0, 2 π},
  BoundaryStyle -> Directive[Thick, Blue], 
  MeshFunctions -> {# &, #2 &, #3 &}, Mesh -> {{0}, {0}, {0}}, 
  MeshStyle -> (Directive[Thick, #] & /@ {Red, Blue, Green}), 
  PlotStyle -> Opacity[.3], 
  PlotRange -> {{-4, 4}, {-3, 3}, {-3, 3}}, Axes -> True, 
  AxesOrigin -> {0, 0, 0}, Ticks -> False]

enter image description here

Post-process to project the lines to three walls:

Normal[pp3d] /. Line[x_, ___] :> 
  {Line[x], Line[x /. {a_, b_, c_} :> {-4, b, c}], 
   Line[x /. {a_, b_, c_} :> {a, 3, c}], 
   Line[x /. {a_, b_, c_} :> {a, b, -3}]}

enter image description here

$\endgroup$
3
$\begingroup$

First, you needs in coordinates of ellipsoid surface points:

a = 1; b = 0.5; c = 0.5;
cp = ContourPlot3D[
  x^2/a^2 + y^2/b^2 + z^2/c^2 == 1, 
  {x, -1.1, 1.1}, {y, -1.1, 1.1}, {z, -1.1, 1.1}][[1,1]];

Further, just make the projections:

cp2d = cp[[All, {1, 2}]];
cm = SortBy[MeshCoordinates[ConvexHullMesh[cp2d]], 
   ArcTan[#[[1]], #[[2]]] &];
cm3dz = Insert[#, 1.1, 3] & /@ cm;
cp2d = cp[[All, {1, 3}]];
cm = SortBy[MeshCoordinates[ConvexHullMesh[cp2d]], 
   ArcTan[#[[1]], #[[2]]] &];
cm3dy = Insert[#, 1.1, 2] & /@ cm;
cp2d = cp[[All, {2, 3}]];
cm = SortBy[MeshCoordinates[ConvexHullMesh[cp2d]], 
   ArcTan[#[[1]], #[[2]]] &];
cm3dx = Insert[#, 1.1, 1] & /@ cm;

Draw the solutions:

Show[cp, 
Graphics3D[{EdgeForm[{Black, Thick}], Transparent, 
Polygon@cm3d, Polygon@cm3dx, Polygon@cm3dy}]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.