[Date Index]
[Thread Index]
[Author Index]
Re: Drawing Potatoes and a Problem with Piecewise
*To*: mathgroup at smc.vnet.net
*Subject*: [mg80196] Re: [mg80121] Drawing Potatoes and a Problem with Piecewise
*From*: Selwyn Hollis <sh2.7183 at earthlink.net>
*Date*: Tue, 14 Aug 2007 07:14:49 -0400 (EDT)
*References*: <200708130830.EAA27361@smc.vnet.net>
David,
Use Exclusions -> None.
- Selwyn
On Aug 13, 2007, at 4:30 AM, David Park wrote:
> Several years ago there was a question on MathGroup on how to draw
> a potato
> in Mathematica.
>
> The SphericalDraw3D documentation has an example of a lumpy sphere
> and I
> decided to turn this into a potato by stretching it by a factor of
> two along
> the z axis. However, to get a reasonable looking potato it is
> necessary to
> damp down the variations in radius near the ends with a weighting
> function.
> So I constructed the following w weighting function using Piecewise.
>
> w[\[Theta]_] = Piecewise[
> {{1/2 (\[Theta]/(\[Pi]/4))^3, 0 <= \[Theta] < \[Pi]/4},
> {1 - 1/2 ((\[Pi]/2 - \[Theta])/(\[Pi]/4))^3, \[Pi]/
> 4 <= \[Theta] < \[Pi]/2},
> {1 + 1/2 ((\[Pi]/2 - \[Theta])/(\[Pi]/4))^3, \[Pi]/2 <= \[Theta] <
> 3 \[Pi]/4},
> {1/2 ((\[Pi] - \[Theta])/(\[Pi]/4))^3,
> 3 \[Pi]/4 <= \[Theta] <= \[Pi]}}]
> Plot[w[\[Theta]], {\[Theta], 0, \[Pi]}, PlotPoints -> 20,
> Frame -> True]
>
> The problem with this is that there are gaps in the function, which
> are more
> or less visible depending on the number of PlotPoints. Am I defining
> Piecewise incorrectly, or is there a bug with Piecewise in plotting
> functions?
>
> So I made another definition of a weighting function, w2, using
> Which, as
> follows:
>
> w2[\[Theta]_] =
> Which[
> 0 <= \[Theta] < \[Pi]/4, (32 \[Theta]^3)/\[Pi]^3,
> \[Pi]/4 <= \[Theta] < \[Pi]/2,
> 1 - (32 (\[Pi]/2 - \[Theta])^3)/\[Pi]^3,
> \[Pi]/2 <= \[Theta] < (3 \[Pi])/4,
> 1 + (32 (\[Pi]/2 - \[Theta])^3)/\[Pi]^3,
> (3 \[Pi])/4 <= \[Theta] <= \[Pi], (
> 32 (\[Pi] - \[Theta])^3)/\[Pi]^3]
> Plot[w2[\[Theta]], {\[Theta], 0, \[Pi]}, PlotPoints -> 20,
> Frame -> True]
>
> This definition causes no problem in plotting. Here is the potato
> with the
> two weighting functions. You can see that the w function leaves the
> potato
> sliced into four pieces.
>
> Table[Show[
> Graphics3D[
> First[SphericalPlot3D[
> 1 + f Sin[5 \[Phi]] Sin[11 \[Theta]]/20, {\[Theta], 0,
> Pi}, {\[Phi], 0, 2 Pi},
> PlotPoints -> {16, 25},
> PlotStyle -> Darker@Brown,
> Mesh -> None]] // Scale[#, {1, 1, 2}, {0, 0, 0}] &],
> ImageSize -> 250], {f, {w[\[Theta]], w2[\[Theta]]}}]
>
>
>
> --
> David Park
> djmpark at comcast.net
> http://home.comcast.net/~djmpark/
>
>
>
Prev by Date:
**Re: Exporting to a 3D file...**
Next by Date:
**Write documentation for Packages**
Previous by thread:
**Re: Drawing Potatoes and a Problem with Piecewise**
Next by thread:
**Re: Drawing Potatoes and a Problem with Piecewise**
| |