Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: calculating the volume of a given shape
Date: Thu, 16 Apr 2009 16:59:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 27
Message-ID: <gs7o4l$smn$1@fred.mathworks.com>
References: <gs4q8u$kg1$1@fred.mathworks.com> <gs6hop$mfh$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1239901141 29399 172.30.248.38 (16 Apr 2009 16:59:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 16 Apr 2009 16:59:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:533270

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gs6hop$mfh$1@fred.mathworks.com>...
>   There is a way to obtain a precise answer for your volume using just a single integration, David.  Its validity depends, as John has pointed out, on your surface not intersecting itself and that depends on the value of ry.  You can tell if that happens by plotting cos(theta) against y(theta) as theta varies from -pi/2 to +pi/2 to see if the curve crosses itself.
> 
>   Cross sections orthogonal to the y-axis yield ellipses of area pi*rx*rz*cos(theta)^2, so you just need to integrate this area along the y-axis.  In some places the total cross section actually consists of an ellipse with a similar ellipse of smaller size cut out of its center.  However, if you express your integral in terms of the parameter theta, this will automatically handle that situation (again provided the surface doesn't intersect itself.)
> 
>   If we abbreviate theta with simply t, you can express the volume as the definite integral of the function
> 
>  f(t) = pi*rx*rz*cos(t)^2 * dy/dt
> 
> taken with respect to t, from t equals -pi/2 to +pi/2.
> 
>   As it turns out, this integral can be evaluated in terms of elementary functions, so numerical methods are not really necessary.  This integrand has three parts: the first part is a constant times cos(t)^3, and the second and third parts are both constants times cos(t)^2*exp(k*t) for two appropriate values of k.  Each of these is of a form that can be evaluated using either integral tables or matlab's 'int' function in the Symbolic Toolbox.
> 
>   The above is the way I would tackle the problem, but I won't spoil things for you by carrying this any further (and anyway it's my bedtime.)

  After a good night's sleep I decided to give you a little more help, David.  The following identities are needed in solving your integration problem along the lines I outlined last night.

 1. 2^u = exp(log(2)*u)
 2. int('cos(t)^3','t',-pi/2,pi/2) = 4/3
 3. int('cos(t)^2*exp(k*t)','t',-pi/2,pi/2) =
      2/k/(k^2+4)*(exp(k*pi/2)-exp(-k*pi/2))

As I asserted earlier, these can be obtained either from a table of integrals or from matlab's symbolic toolbox.

  From these, you should be able to find a precise expression for the volume of your "shape" using the integral of f(t) defined earlier.  Actually you may prefer to use the symbolic toolbox to evaluate the integral of f(t) directly, though the results may look somewhat messier.

Roger Stafford