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
in Mathematica. Thanks.
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
in Mathematica. Thanks.
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]
Post-process to project the lines to three walls:
Normal[pp3d] /. Line[x_, ___] :>
{Line[x], Line /@ (x /.
{{{a_, b_, c_} :> {-4, b, c}},
{{a_, b_, c_} :> {a, 3, c}},
{{a_, b_, c_} :> {a, b, -3}}})}
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}]]