# Plot cross sections of a function

I have been learning how to use Mathematica for the past few weeks, and recently I have been trying to recreate something along the lines of this.

Given a function, I want to create a 3d plot of an object as if the bounded regions of the function were to be extruded upwards in a certain shape. From this I hope to find a basic volume, instead of integrating. How would I do this? I have seen ParametricPlot3D, but I haven't been able to create what I want with it.

-
Your diagram suggests that the triangle cross-sections are equilateral triangles. Is actually the case, or is it an artifact of the projection? – m_goldberg Feb 1 '13 at 6:36
They should be equilateral triangles. Similar to the integration problems where you are asked to find the volume of objects. Here it would be find the volume of an object whose cross sections are equilateral triangles and base is defined by sinx and -sinx. – a sandwhich Feb 1 '13 at 18:36

 ParametricPlot3D[{v {u, Sin[u], 0} + (1 - v) {u, -Sin[u], 0},
ConditionalExpression[v {u, Sin[u], 0} + (1 - v) {u, 0, Sin[u]},  0 <= u <= Pi],
ConditionalExpression[v {u, -Sin[u], 0} + (1 - v) {u, 0, Sin[u]}, 0 <= u <= Pi],
{u, 0, Sin[u]}},
{u, -1, 4}, {v, 0, 1},
PlotStyle -> Opacity[.5, White], Lighting -> "Neutral",
Boxed -> False, Axes -> True, BoxRatios -> {2, 1, 1},
MeshFunctions -> {Function[{x, y, z, u, v}, u], Function[{x, y, z, u, v}, v]},
Mesh -> {Range[0, Pi, Pi/4], {0, 1}},
MeshStyle -> {Directive[Dashed, Red], Directive[Thick, Blue]},
PlotRange -> Full, ImageSize -> 500, AxesOrigin -> {0, 0, 0},
Ticks -> {{Pi/2, Pi}, {-1/2, -1}, {1/2, 1}},
PlotRangePadding -> .2,  AxesStyle -> Thick, ImageSize -> 500]


Update: a first attempt to use RegionPlot3D:

 RegionPlot3D[-Abs@Sin[x] <= Abs@y <= Abs@Sin[x] && z + Abs@y <= Abs@Sin[x] && 0 <= z,
{x, 0, Pi}, {y, -1, 1}, {z, -1, 1},
PlotRange -> {{-1, Pi + 1/2}, {-1, 1}, {-1, 1}},
BoxRatios -> {2, 1, 1},
PlotStyle -> Directive[White, Opacity[0.6]], Lighting -> "Neutral",
PlotPoints -> 35,
MeshFunctions -> {#1 &, #2 &, #3 &},
Mesh -> {{.5, 1., 1.5, 2., 2.1, 2.2, 2.3}, {0.}, {0.}},
MeshStyle -> {Directive[Thin, Gray], Directive[Thick, Blue], Directive[Thick, Blue]},
Axes -> True, AxesStyle -> Thick,
AxesOrigin -> {0, 0, 0}, Ticks -> {{Pi/2, Pi}, {-1/2, -1}, {1/2, 1}},
ImageSize -> 500, Boxed -> False]


-
+1 very nice indeed. It has even a hand drawn look! – chris Feb 1 '13 at 8:18
thank you @chris. hand-drawn-look made with poor-man's built-in xkcd-style (resize the cropped image):) – kglr Feb 1 '13 at 9:01