# Ad hoc graphics primitives-like objects

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.

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}}]]


• Nice use of [[1]] to extract the GraphicsComplex from the plot! Commented Mar 19, 2012 at 14:22
• Or slightly more transparently: Cases[(* stuff *), _GraphicsComplex, Infinity] // First. Commented Mar 19, 2012 at 15:21
• Or if you are baffled by GraphicsComplex, try Cases[Normal[plot], _Polygon, Infinity] which will return the (many many) constituting polygons. Commented Mar 19, 2012 at 16:34

I think what you're looking for is BSplineSurface. For your given example, try:

cpts = Table[{x, y, Exp[-(x^2 + y^2)]}, {x, -2, 2, 0.1}, {y, -2, 2,
0.1}];

Graphics3D[BSplineSurface[cpts], Boxed -> False]


Which gives: