7
$\begingroup$

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.

enter image description here

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.

$\endgroup$
2
  • $\begingroup$ Your diagram suggests that the triangle cross-sections are equilateral triangles. Is actually the case, or is it an artifact of the projection? $\endgroup$
    – m_goldberg
    Commented Feb 1, 2013 at 6:36
  • $\begingroup$ 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. $\endgroup$ Commented Feb 1, 2013 at 18:36

1 Answer 1

14
$\begingroup$
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]

enter image description here

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]

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.