3
$\begingroup$

Suppose I want to demnstrate two ellispoids; one with the center at the origin and the other translated.

After the advice I got in the last question I use

ellipse3D[centre_: {0, 0, 0}, radii_: {1, 1}, normal_: {0, 0, 1}] := 
 Polygon[RotationTransform[{{0, 0, 1}, normal}, centre][
   Map[Append[#, Last@centre] &][
    SortBy[#, N[ArcTan @@ (# - Most@centre)] &] &[
     MeshCoordinates[
      BoundaryDiscretizeRegion[Ellipsoid[Most@centre, radii]]]]]]]

arrowAxesXYZ[{a_, b_, c_}] := 
 Map[Arrow[Tube[{{0, 0, 0}, #}]] &, {a + 2, b + 2, 
    c + 2} IdentityMatrix[3]]
AxesXYZ[{a_, b_, c_}] := {Text[
   Style["X", 20, Italic], {a + 2.2, 0, 0}], 
  Text[Style["Y", 20, Italic], {0, b + 2.2, 0}], 
  Text[Style["Z", 20, Italic], {0, 0, c + 2.2}]}

EllipsoidXYZ[{a_, b_, c_}] := {{Specularity[White, 40], Opacity[0.5], 
   Ellipsoid[{0, 0, 0}, {a, b, c}]}, {Gray, Opacity[1], 
   EdgeForm[None], ellipse3D[{0, 0, 0}, {c, b}, {1, 0, 0}], 
   ellipse3D[{0, 0, 0}, {a, c}, {0, 1, 0}], 
   ellipse3D[{0, 0, 0}, {a, b}, {0, 0, 1}]}}

translatedEllipsoidXYZ[{a_, b_, c_}, {d_, e_, f_}] := 
 Translate[EllipsoidXYZ[{a, b, c}], {d, e, f}]
translateAxesXYZ[{a_, b_, c_}, {d_, e_, f_}] := 
 Translate[arrowAxesXYZ[{a, b, c}], {d, e, f}]
vectorofTranslation[{d_, e_, f_}] := {Gray, 
  Arrow[Tube[{{0, 0, 0}, {d, e, f}}, 0.05]]}

Show[Graphics3D[{EllipsoidXYZ[{10, 3, 2}], arrowAxesXYZ[{10, 3, 2}], 
   AxesXYZ[{10, 3, 2}], 
   translatedEllipsoidXYZ[{10, 3, 2}, {15, 7, 4}], 
   translateAxesXYZ[{10, 3, 2}, {15, 7, 4}], 
   vectorofTranslation[{15, 7, 4}]}], ImageSize -> 600]

taking

enter image description here

My question is how can someone modify this output? Saying for instance that we want
a) Get rid of the cross sections of the translated ellipsoid. b) Modify the opacity of the translated ellipsoid. c) Modify the apppearance of the translated axis.

I could add arguments in the definitions but I am wondering how in general we can modify a complex graphics3D after its creation.

If you are lost in the various definitions, it suffices to me a minimal example of "how-to-approach".

$\endgroup$
2
  • $\begingroup$ Seems to me you want to use a Manipulate and have all of these as options, check boxes and sliders $\endgroup$
    – Jason B.
    Commented Nov 20, 2015 at 12:51
  • $\begingroup$ Hi. The ulterio objective is to upgrade what I did here mathematica.stackexchange.com/questions/97972/… but using the new built-in symbols of Mathematica and the experience I have obtained. But instead of giving a "whole" question, I splitted it into sevral sub-questions. Of course I want in the very end to use Manipulate. $\endgroup$
    – Dimitris
    Commented Nov 20, 2015 at 12:55

1 Answer 1

3
$\begingroup$

The basic answer to "how in general we can modify a complex graphics3D after its creation?" is to define each subelement of the 3D graphic as a separate entity, then combine them together with Show. Next you choose which ones to show by setting boolean variables, which you either define beforehand or manipulating them.

Too many different questions in there, but this should give a general idea on how to have people modify the graphics,

Manipulate[Module[
  {ellps, xdisk, ydisk, zdisk},
  ellps = {Specularity[White, 40], Opacity[opac], 
    Ellipsoid[{0, 0, 0}, {10, 3, 2}]};
  xdisk = {Opacity[1], EdgeForm[None], 
    ellipse3D[{0, 0, 0}, {2, 3}, {1, 0, 0}]};
  ydisk =  {Opacity[1], EdgeForm[None], 
    ellipse3D[{0, 0, 0}, {10, 2}, {0, 1, 0}]};
  zdisk =  {Opacity[1], EdgeForm[None], 
    ellipse3D[{0, 0, 0}, {10, 3}, {0, 0, 1}]};
  Graphics3D[Join[
    {ellps},
    {If[xtrue, xdisk]},
    {If[ytrue, ydisk]},
    {If[ztrue, zdisk]}
    ]
   ]
  ], {{xtrue, True, "X plane"}, {True, False}},
 {{ytrue, True, "Y plane"}, {True, False}},
 {{ztrue, True, "Z plane"}, {True, False}},
 {{opac, 0.5, "Ellipsoid Opacity"}, 0, 1}]

enter image description here

$\endgroup$
1
  • $\begingroup$ What about imported stl? Suppose I have an STL imported as Graphics3D or GraphicsComplex, I would like to change color and transparency, how to do that? $\endgroup$
    – Fabio
    Commented Nov 30, 2015 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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