Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross Section - Mathematica

If you have Mathematica and input:

ParametricPlot3D[{Sin[u], Sin[v], Sin[u + v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi]

You will generate a 3D solid that looks like a cube with crushed in sides. What I want to do is take cross sections of this solid with the horizontal planes: z = 0, z = 1, z= -1, z= 1/2, and z= -1/2.

What is the command to generate plots of these cross sections?

like image 488
user1371252 Avatar asked Jan 16 '23 19:01

user1371252


2 Answers

This can be done by specifying a RegionFunction, which is a boolean condition that determines where the surface is allowed to be plotted. Here, you would use

RegionFunction -> Function[{x, y, z}, z < a]

where a is the height at which you want the intersecting plane to be. To illustrate this, I'll make a movie:

t = Table[
  ParametricPlot3D[{Sin[u], Sin[v], Sin[u + v]}, {u, 0, 2 Pi}, {v, 0, 
    2 Pi}, RegionFunction -> Function[{x, y, z}, z < a], 
   PlotRange -> {{-1, 1}, {-1, 1}, {-1, 1}}], 
 {a, 1, -1, -.1}
]

And now I'll export it as a GIF animation to include below:

Export["section.gif", Join[t, Rest[Reverse[t]]]]

Sections

like image 199
Jens Avatar answered Mar 08 '23 16:03

Jens


To just get the intersection curves you could use the MeshFunctions and Mesh options, e.g.

ParametricPlot3D[{Sin[u], Sin[v], Sin[u + v]}, {u, 0, 2 Pi}, {v, 0, 2 Pi},
 MeshFunctions -> {#3 &}, Mesh -> {Range[-1, 1, 1/2]}, 
 PlotStyle -> None, PlotPoints -> 50]

Mathematica graphics

like image 26
Heike Avatar answered Mar 08 '23 15:03

Heike