function result = pyramid_unit_o27_3d ( func )

%*****************************************************************************80
%
%% PYRAMID_UNIT_O27_3D approximates an integral inside the unit pyramid in 3D.
%
%  Discussion:
%
%    A 27 point formula is used.
%
%    The (X,Y,Z) integration region can be represented as:
%
%    - ( 1 - Z ) <= X <= 1 - Z
%    - ( 1 - Z ) <= Y <= 1 - Z
%              0 <= Z <= 1.
%
%    When Z is zero, the integration region is a square lying in the (X,Y)
%    plane, centered at (0,0,0) with "radius" 1.  As Z increases to 1, the
%    radius of the square diminishes, and when Z reaches 1, the square has
%    contracted to the single point (0,0,1).
%
%  Licensing:
%
%    This code is distributed under the GNU LGPL license.
%
%  Modified:
%
%    01 April 2008
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Carlos Felippa,
%    A compendium of FEM integration formulas for symbolic work,
%    Engineering Computation,
%    Volume 21, Number 8, 2004, pages 867-890.
%
%  Parameters:
%
%    Input, external FUNC, the name of the user supplied function which
%    evaluates F(X,Y,Z), of the form
%      function value = func ( x, y, z )
%
%    Output, real RESULT, the approximate integral of the function.
%
  order = 27;

  w = [ ...
   0.036374157653908938268, ...
   0.05819865224625430123, ...
   0.036374157653908938268, ...
   0.05819865224625430123, ...
   0.09311784359400688197, ...
   0.05819865224625430123, ...
   0.036374157653908938268, ...
   0.05819865224625430123, ...
   0.036374157653908938268, ...
   0.033853303069413431019, ...
   0.054165284911061489631, ...
   0.033853303069413431019, ...
   0.054165284911061489631, ...
   0.08666445585769838341, ...
   0.054165284911061489631, ...
   0.033853303069413431019, ...
   0.054165284911061489631, ...
   0.033853303069413431019, ...
   0.006933033103838124540, ...
   0.011092852966140999264, ...
   0.006933033103838124540, ...
   0.011092852966140999264, ...
   0.017748564745825598822, ...
   0.011092852966140999264, ...
   0.006933033103838124540, ...
   0.011092852966140999264, ...
   0.006933033103838124540 ]';
  x = [ ...
  -0.7180557413198889387, ...
   0.00000000000000000000, ...
   0.7180557413198889387, ...
  -0.7180557413198889387, ...
   0.00000000000000000000, ...
   0.7180557413198889387, ...
  -0.7180557413198889387, ...
   0.00000000000000000000, ...
   0.7180557413198889387, ...
  -0.50580870785392503961, ...
   0.00000000000000000000, ...
   0.50580870785392503961, ...
  -0.50580870785392503961, ...
   0.00000000000000000000, ...
   0.50580870785392503961, ...
  -0.50580870785392503961, ...
   0.00000000000000000000, ...
   0.50580870785392503961, ...
  -0.22850430565396735360, ...
   0.00000000000000000000, ...
   0.22850430565396735360, ...
  -0.22850430565396735360, ...
   0.00000000000000000000, ...
   0.22850430565396735360, ...
  -0.22850430565396735360, ...
   0.00000000000000000000, ...
   0.22850430565396735360 ]';
  y = [ ...
  -0.7180557413198889387, ...
  -0.7180557413198889387, ...
  -0.7180557413198889387, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.7180557413198889387, ...
   0.7180557413198889387, ...
   0.7180557413198889387, ...
  -0.50580870785392503961, ...
  -0.50580870785392503961, ...
  -0.50580870785392503961, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.50580870785392503961, ...
   0.50580870785392503961, ...
   0.50580870785392503961, ...
  -0.22850430565396735360, ...
  -0.22850430565396735360, ...
  -0.22850430565396735360, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.00000000000000000000, ...
   0.22850430565396735360, ...
   0.22850430565396735360, ...
   0.22850430565396735360 ]';
  z = [ ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.07299402407314973216, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.34700376603835188472, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312, ...
  0.70500220988849838312 ]';
%
%  Quadrature.
%
  quad = 0.0;
  for i = 1 : order
    quad = quad + w(i) * feval ( func, x(i), y(i), z(i) );
  end
%
%  Volume.
%
  volume = pyramid_unit_volume_3d ( );
%
%  Result.
%
  result = quad * volume;

  return
end
