开发者

Mathematica: Removing graphics primitives

Given that g is a graphics object with primitives such as Lines and Polygons, how do you remove some of them? To add more primitives to an existing graphics object we can use Show, for instance: Show[g, g2] where g2 is another graphics object with other primitives. But how do you remove unwanted primitive objects? Take a look at the following

ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}}, Mesh -> {1, 1}]

Mathematica: Removing graphics primitives

Now, for the input form:

InputForm[
   ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}}, Mesh -> {1, 1}]
 ]

Mathematica: Removing graphics primitives

To create a wire frame from this object all we have to do is remove the polygons. As an extra we can also remove the vertex normals since they don't contribute to the wireframe.

Notice that to make a wireframe we can simply set PlotStyle -> None as an option in ListPlot3D. This gets rid of the Polygons but doesn't remove the VertexNormals.

To clarify the question. Given that

 g = ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}}, Mesh -> {1, 1}]

How do you remove some of the of the graphics primitives f开发者_JS百科rom g and how do you remove some of the options, i.e. VertexNormals? Note: option VertexNormals is an option of GraphicsComplex.

If this is not possible then maybe the next question would be, how do you obtain the data used to generate g to generate a new graphics object with some of the data obtained from g.


One way is to use transformation rules. Given your

im = ListPlot3D[{{0, 0, 1}, {1, 0, 0}, {0, 1, 0}, {1, 1, 0}},  Mesh -> {1, 1}]

You can do

newim = im /. {_Polygon :> Sequence[], (VertexNormals -> _) :> Sequence[]}

or, more compactly using Alternatives:

newim = im /. _Polygon | (VertexNormals -> _) :> Sequence[]

You could also use DeleteCases to get a similar effect:

newim = DeleteCases[im, (_Polygon | (VertexNormals -> _)), Infinity]

Mathematica: Removing graphics primitives

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜