Sphere
is one of the three-dimensional graphics primitives available in Mathematica and can be easily used to created very useful images. For instance, in the figure below I created three images of an ellipsoidal object that is lit from a fixed direction and it is then just rotated around the z-axis.
GraphicsRow[
Table[
Graphics3D[
Rotate[Scale[{GrayLevel[.7], Sphere[]}, {1, 1.5, 1}, {0, 0, 0}],
i Degree, {0, 0, 1}], PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}},
AspectRatio -> 1, Background -> Black, Boxed -> False,
ViewPoint -> Front, SphericalRegion -> True,
Lighting -> {{"Directional", White, ImageScaled[{0, 0, 1}]}}
], {i, {0, 45, 90}}]]
Suppose that instead of using the ellipsoidal object I would like to use an object like this bump:
Plot3D[Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}]
Is there a way to create a "graphics primitive" object of the bump, so as to just use it instead of Sphere
in the above example?
I suppose there should be a way to extract all the polygons specifying the shape of the bump, but I couldn't find a way to do it. Any other approach is also more than welcome.
Answer
The result of Plot3D
and related functions is something of the form Graphics3D[primitives, options]
, so to extract the graphics primitives you can simply take the first part of the plot. These can then be manipulated similar to Sphere[]
in your example, e.g.
plot = Plot3D[Exp[-(x^2 + y^2)], {x, -2, 2}, {y, -2, 2}][[1]];
GraphicsRow[
Table[Graphics3D[
Rotate[Scale[{GrayLevel[.7], plot}, {1, 1.5, 1}, {0, 0, 0}],
i Degree, {0, 0, 1}], PlotRange -> {{-2, 2}, {-2, 2}, {-2, 2}},
AspectRatio -> 1, Background -> Black, Boxed -> False,
ViewPoint -> Front, SphericalRegion -> True,
Lighting -> {{"Directional", White,
ImageScaled[{0, 0, 1}]}}], {i, {0, 45, 90}}]]
Comments
Post a Comment