Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #6810 > unrolled thread
| Started by | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| First post | 2011-11-29 12:10 +0000 |
| Last post | 2011-11-30 08:31 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: Ragged region boundary Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-11-29 12:10 +0000
Re: Ragged region boundary Chris Young <cy56@comcast.net> - 2011-11-29 13:06 +0000
Re: Ragged region boundary Patrick Scheibe <pscheibe@trm.uni-leipzig.de> - 2011-11-30 08:31 +0000
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Date | 2011-11-29 12:10 +0000 |
| Subject | Re: Ragged region boundary |
| Message-ID | <jb2i3g$5hk$1@smc.vnet.net> |
Hi,
first you could compile your torus-function and compare the runtimes
torus[c_, a_, u_, v_] := {(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u],
a Sin[v]};
torusCompiled =
Compile[{{c, _Real}, {a, _Real}, {u, _Real}, {v, _Real}},
{(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u], a Sin[v]},
CompilationTarget -> "C"];
In[38]:= First[
AbsoluteTiming[Do[#[1.3, 0.3, 2.3, 4.5], {1000000}]]] & /@ {torus,
torusCompiled}
Out[38]= {5.190318, 0.863473}
and then you could set MaxRecursion to a higher value. Since then the
runtime drops further, you could use ControlActive to use a very fast
version, when you use the sliders. See the code at the end.
Your "equator" is not the only unwanted boundary, but you don't see the
other one. These are the lines where your PlotRange ends. The doc to
BoundaryStyle says
"For 3D graphics, it is also used at the boundary of regions defined by
PlotRange."
So these lines are at 0 and 2Pi for both of your variables. I have no
idea how to turn them off.
Cheers
Patrick
Manipulate[
ParametricPlot3D[
torusCompiled[c, a, u, v], {u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]},
MeshFunctions -> {{x, y, z, \[Theta], \[Phi]} \[Function]
z + Tan[tilt] x},
RegionFunction -> ({x, y, z, \[Theta], \[Phi]} \[Function]
z <= -Tan[tilt] x),
Mesh -> mesh,
MaxRecursion -> ControlActive[0, 5],
MeshStyle -> {Lighter[Yellow], Tube[tubeR]},
BoundaryStyle -> {Lighter[Red], Tube[tubeR]},
PlotStyle -> {Orange, Opacity[opac]},
PlotPoints -> ControlActive[10, plotPts],
Axes -> True,
AxesLabel -> {"x", "y", "z"},
PlotRange -> {{-4, 4}, {-4, 4}, {-3, 3}},
BoxRatios -> {8, 8, 6},
ViewPoint ->
{
viewR Cos[view\[Theta]] Sin[view\[Phi]],
viewR Sin[view\[Theta]] Sin[view\[Phi]],
viewR Cos[view\[Phi]]
},
PerformanceGoal -> "Quality"
],
{{c, 3}, 0, 4},
{{a, 1}, 0, 3},
{{sphereR, 0.1}, 0, 0.5},
{{tubeR, 0.05}, 0, 0.5},
{{opac, 0.5}, 0, 1},
{{mesh, 0}, 0, 16, 1},
{{tilt, N[ArcSin[a/c]]}, 0, \[Pi]/2, \[Pi]/36},
{{plotPts, 50}, 0, 200, 5},
{{viewR, 100}, 0, 100, 5},
{{view\[Theta], \[Pi]/2}, 0, 2 \[Pi], \[Pi]/36},
{{view\[Phi], \[Pi]/2}, 0, \[Pi], \[Pi]/36}
]
On Mon, 2011-11-28 at 05:54 -0500, Chris Young wrote:
> Would anyone have any tips on how to get a better region boundary here?
> Maybe via CountourPlot3D?
>
> Actually, if I use PlotPoints -> 200, it's OK, but it's extremely slow
> to plot then, of course.
>
> Also, I don't want the horizontal "boundary" line at the equator. Can't
> see why this is considered a boundary line anyway.
>
> http://home.comcast.net/~cy56/RegionBoundary.nb
>
> http://home.comcast.net/~cy56/RegionBoundary.png
>
>
> Manipulate[
> ParametricPlot3D[
> torus[c, a, u, v], {u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]},
> MeshFunctions -> {{x, y, z, \[Theta], \[Phi]} \[Function]
> z + Tan[tilt] x},
> RegionFunction -> ({x, y, z, \[Theta], \[Phi]} \[Function]
> z <= -Tan[tilt] x),
> Mesh -> mesh,
> MeshStyle -> {Lighter[Yellow], Tube[tubeR]},
> BoundaryStyle -> {Lighter[Red], Tube[tubeR]},
> PlotStyle -> {Orange, Opacity[opac]},
> PlotPoints -> plotPts,
> Axes -> True,
> AxesLabel -> {"x", "y", "z"},
> PlotRange -> {{-4, 4}, {-4, 4}, {-3, 3}},
> BoxRatios -> {8, 8, 6},
> ViewPoint ->
> {
> viewR Cos[view\[Theta]] Sin[view\[Phi]],
> viewR Sin[view\[Theta]] Sin[view\[Phi]],
> viewR Cos[view\[Phi]]
> },
> PerformanceGoal -> "Quality"
> ],
>
> {{c, 3}, 0, 4},
> {{a, 1}, 0, 3},
> {{sphereR, 0.1}, 0, 0.5},
> {{tubeR, 0.05}, 0, 0.5},
> {{opac, 0.5}, 0, 1},
> {{mesh, 1}, 0, 16, 1},
> {{tilt, N[ArcSin[a/c]]}, 0, \[Pi]/2, \[Pi]/36},
> {{plotPts, 50}, 0, 100, 5},
> {{viewR, 100}, 0, 100, 5},
> {{view\[Theta], \[Pi]/2}, 0, 2 \[Pi], \[Pi]/36},
> {{view\[Phi], \[Pi]/2}, 0, \[Pi], \[Pi]/36}
> ]
>
>
[toc] | [next] | [standalone]
| From | Chris Young <cy56@comcast.net> |
|---|---|
| Date | 2011-11-29 13:06 +0000 |
| Message-ID | <jb2ld2$6q5$1@smc.vnet.net> |
| In reply to | #6810 |
This looks like a great idea. Thanks very much. Unfortunately, I can't
seem to find a C compiler on my Mac. Maybe Apple is charging for the
development package now, I don't know. I'll look into it.
In[80]:= Needs["CCompilerDriver`"]
In[86]:= CCompilers[]
Out[86]= {}
On 2011-11-29 12:10:24 +0000, Patrick Scheibe said:
> Hi,
>
> first you could compile your torus-function and compare the runtimes
>
> torus[c_, a_, u_, v_] := {(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u],
> a Sin[v]};
> torusCompiled =
> Compile[{{c, _Real}, {a, _Real}, {u, _Real}, {v, _Real}},
> {(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u], a Sin[v]},
> CompilationTarget -> "C"];
>
> In[38]:= First[
> AbsoluteTiming[Do[#[1.3, 0.3, 2.3, 4.5], {1000000}]]] & /@ {torus,
> torusCompiled}
>
> Out[38]= {5.190318, 0.863473}
>
> and then you could set MaxRecursion to a higher value. Since then the
> runtime drops further, you could use ControlActive to use a very fast
> version, when you use the sliders. See the code at the end.
>
> Your "equator" is not the only unwanted boundary, but you don't see the
> other one. These are the lines where your PlotRange ends. The doc to
> BoundaryStyle says
>
> "For 3D graphics, it is also used at the boundary of regions defined by
> PlotRange."
>
> So these lines are at 0 and 2Pi for both of your variables. I have no
> idea how to turn them off.
>
> Cheers
> Patrick
>
> Manipulate[
> ParametricPlot3D[
> torusCompiled[c, a, u, v], {u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]},
> MeshFunctions -> {{x, y, z, \[Theta], \[Phi]} \[Function]
> z + Tan[tilt] x},
> RegionFunction -> ({x, y, z, \[Theta], \[Phi]} \[Function]
> z <= -Tan[tilt] x),
> Mesh -> mesh,
> MaxRecursion -> ControlActive[0, 5],
> MeshStyle -> {Lighter[Yellow], Tube[tubeR]},
> BoundaryStyle -> {Lighter[Red], Tube[tubeR]},
> PlotStyle -> {Orange, Opacity[opac]},
> PlotPoints -> ControlActive[10, plotPts],
> Axes -> True,
> AxesLabel -> {"x", "y", "z"},
> PlotRange -> {{-4, 4}, {-4, 4}, {-3, 3}},
> BoxRatios -> {8, 8, 6},
> ViewPoint ->
> {
> viewR Cos[view\[Theta]] Sin[view\[Phi]],
> viewR Sin[view\[Theta]] Sin[view\[Phi]],
> viewR Cos[view\[Phi]]
> },
> PerformanceGoal -> "Quality"
> ],
>
> {{c, 3}, 0, 4},
> {{a, 1}, 0, 3},
> {{sphereR, 0.1}, 0, 0.5},
> {{tubeR, 0.05}, 0, 0.5},
> {{opac, 0.5}, 0, 1},
> {{mesh, 0}, 0, 16, 1},
> {{tilt, N[ArcSin[a/c]]}, 0, \[Pi]/2, \[Pi]/36},
> {{plotPts, 50}, 0, 200, 5},
> {{viewR, 100}, 0, 100, 5},
> {{view\[Theta], \[Pi]/2}, 0, 2 \[Pi], \[Pi]/36},
> {{view\[Phi], \[Pi]/2}, 0, \[Pi], \[Pi]/36}
> ]
[toc] | [prev] | [next] | [standalone]
| From | Patrick Scheibe <pscheibe@trm.uni-leipzig.de> |
|---|---|
| Date | 2011-11-30 08:31 +0000 |
| Message-ID | <jb4pk4$gus$1@smc.vnet.net> |
| In reply to | #6810 |
Hi,
you have to install the XCode-tools separately, but they should be on
one of the DVDs you got. I always get XCode when buying an Apple.
But you don't have to use necessarily the "C" option. Just use Compile
and it should be faster.
Cheers
Patrick
On Tue, 2011-11-29 at 08:06 -0500, Chris Young wrote:
> This looks like a great idea. Thanks very much. Unfortunately, I can't
> seem to find a C compiler on my Mac. Maybe Apple is charging for the
> development package now, I don't know. I'll look into it.
>
> In[80]:= Needs["CCompilerDriver`"]
> In[86]:= CCompilers[]
> Out[86]= {}
>
> On 2011-11-29 12:10:24 +0000, Patrick Scheibe said:
>
> > Hi,
> >
> > first you could compile your torus-function and compare the runtimes
> >
> > torus[c_, a_, u_, v_] := {(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u],
> > a Sin[v]};
> > torusCompiled =
> > Compile[{{c, _Real}, {a, _Real}, {u, _Real}, {v, _Real}},
> > {(c + a Cos[v]) Cos[u], (c + a Cos[v]) Sin[u], a Sin[v]},
> > CompilationTarget -> "C"];
> >
> > In[38]:= First[
> > AbsoluteTiming[Do[#[1.3, 0.3, 2.3, 4.5], {1000000}]]] & /@ {torus,
> > torusCompiled}
> >
> > Out[38]= {5.190318, 0.863473}
> >
> > and then you could set MaxRecursion to a higher value. Since then the
> > runtime drops further, you could use ControlActive to use a very fast
> > version, when you use the sliders. See the code at the end.
> >
> > Your "equator" is not the only unwanted boundary, but you don't see the
> > other one. These are the lines where your PlotRange ends. The doc to
> > BoundaryStyle says
> >
> > "For 3D graphics, it is also used at the boundary of regions defined by
> > PlotRange."
> >
> > So these lines are at 0 and 2Pi for both of your variables. I have no
> > idea how to turn them off.
> >
> > Cheers
> > Patrick
> >
> > Manipulate[
> > ParametricPlot3D[
> > torusCompiled[c, a, u, v], {u, 0, 2 \[Pi]}, {v, 0, 2 \[Pi]},
> > MeshFunctions -> {{x, y, z, \[Theta], \[Phi]} \[Function]
> > z + Tan[tilt] x},
> > RegionFunction -> ({x, y, z, \[Theta], \[Phi]} \[Function]
> > z <= -Tan[tilt] x),
> > Mesh -> mesh,
> > MaxRecursion -> ControlActive[0, 5],
> > MeshStyle -> {Lighter[Yellow], Tube[tubeR]},
> > BoundaryStyle -> {Lighter[Red], Tube[tubeR]},
> > PlotStyle -> {Orange, Opacity[opac]},
> > PlotPoints -> ControlActive[10, plotPts],
> > Axes -> True,
> > AxesLabel -> {"x", "y", "z"},
> > PlotRange -> {{-4, 4}, {-4, 4}, {-3, 3}},
> > BoxRatios -> {8, 8, 6},
> > ViewPoint ->
> > {
> > viewR Cos[view\[Theta]] Sin[view\[Phi]],
> > viewR Sin[view\[Theta]] Sin[view\[Phi]],
> > viewR Cos[view\[Phi]]
> > },
> > PerformanceGoal -> "Quality"
> > ],
> >
> > {{c, 3}, 0, 4},
> > {{a, 1}, 0, 3},
> > {{sphereR, 0.1}, 0, 0.5},
> > {{tubeR, 0.05}, 0, 0.5},
> > {{opac, 0.5}, 0, 1},
> > {{mesh, 0}, 0, 16, 1},
> > {{tilt, N[ArcSin[a/c]]}, 0, \[Pi]/2, \[Pi]/36},
> > {{plotPts, 50}, 0, 200, 5},
> > {{viewR, 100}, 0, 100, 5},
> > {{view\[Theta], \[Pi]/2}, 0, 2 \[Pi], \[Pi]/36},
> > {{view\[Phi], \[Pi]/2}, 0, \[Pi], \[Pi]/36}
> > ]
>
>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web