ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 19 Aug 2012 14:19:49 -0500filling in an area under a function or curve in 3 dimensionshttp://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/I am new to Sage, and I couldn't find an answer to two question in the documentation. First, how do I get sage to plot a parametric curve in 3 dimensions, and then fill in the area between the curve and the xy-plane (i.e., I want sage to drop down a "sheet" from the curve to the xy-plane)? Similarly, how do I get Sage to plot a function in 3 dimensions (say, $f(x,y)=x^2y+10)$), and tell sage to fill in the volume under the graph between the function and the xy-plane? So for the function $f$ just mentioned, I would like the volume under the curve filled in over the rectangle $1 \leq x \leq 3$, $0 \leq y \leq 5$. How do I do that? Thanks!Sun, 19 Aug 2012 08:44:48 -0500http://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/Answer by achrzesz for <p>I am new to Sage, and I couldn't find an answer to two question in the documentation. First, how do I get sage to plot a parametric curve in 3 dimensions, and then fill in the area between the curve and the xy-plane (i.e., I want sage to drop down a "sheet" from the curve to the xy-plane)? Similarly, how do I get Sage to plot a function in 3 dimensions (say, $f(x,y)=x^2y+10)$), and tell sage to fill in the volume under the graph between the function and the xy-plane? So for the function $f$ just mentioned, I would like the volume under the curve filled in over the rectangle $1 \leq x \leq 3$, $0 \leq y \leq 5$. How do I do that? Thanks!</p>
http://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/?answer=13945#post-id-13945In the case of 3d curve you can try something like:
var('t u')
p1=parametric_plot3d([cos(u),sin(u),u^2],(u,-1,1),thickness=10)
p2=sum([line([(cos(t),sin(t),0),(cos(t),sin(t),t^2)]) for t in srange(-1,1,0.02)])
p1+p2
In the case of 3d surface:
var('x y')
f(x,y)=x^2*y+10
p0=plot3d(f(x,y),(x,1,3),(y,0,5),opacity=0.2)+plot3d(0,(x,1,3),(y,0,5),opacity=0.2)
p1=sum([line([(t,0,0),(t,0,f(t,0))]) for t in srange(1,3,0.02)])
p2=sum([line([(3,u,0),(3,u,f(3,u))]) for u in srange(0,5,0.1)])
p0+p1+p2Sun, 19 Aug 2012 11:01:02 -0500http://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/?answer=13945#post-id-13945Comment by strangelove1221 for <p>In the case of 3d curve you can try something like:</p>
<pre><code>var('t u')
p1=parametric_plot3d([cos(u),sin(u),u^2],(u,-1,1),thickness=10)
p2=sum([line([(cos(t),sin(t),0),(cos(t),sin(t),t^2)]) for t in srange(-1,1,0.02)])
p1+p2
</code></pre>
<p>In the case of 3d surface:</p>
<pre><code>var('x y')
f(x,y)=x^2*y+10
p0=plot3d(f(x,y),(x,1,3),(y,0,5),opacity=0.2)+plot3d(0,(x,1,3),(y,0,5),opacity=0.2)
p1=sum([line([(t,0,0),(t,0,f(t,0))]) for t in srange(1,3,0.02)])
p2=sum([line([(3,u,0),(3,u,f(3,u))]) for u in srange(0,5,0.1)])
p0+p1+p2
</code></pre>
http://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/?comment=19201#post-id-19201Thanks for the help. Sun, 19 Aug 2012 14:19:49 -0500http://ask.sagemath.org/question/9253/filling-in-an-area-under-a-function-or-curve-in-3-dimensions/?comment=19201#post-id-19201