rss
Twitter Delicious Facebook Digg Stumbleupon Favorites

Friday, October 7, 2011

Find the area and volume of a pyramid

In geometry, a pyramid is a polyhedron formed by connecting a polygonal base and a point, called the apex. Each base edge and apex form a triangle. It is a conic solid with polygonal base.

 
A pyramid with an n-sided base will have n + 1 vertices, n + 1 faces, and 2n edges. All pyramids are self-dual.
When unspecified, the base is usually assumed to be square.
If the base is a regular polygon and the apex is above the center of the polygon, an n-gonal pyramid will have Cnv symmetry.
Pyramids are a subclass of the prismatoids.
The volume of a pyramid is V= \tfrac{1}{3}Bh where B is the area of the base and h the height from the base to the apex. This works for any location of the apex, provided that h is measured as the perpendicular distance from the plane which contains the base. In 499 AD Aryabhata, a mathematician-astronomer from the classical age of Indian mathematics and Indian astronomy, used this method in the Aryabhatiya (section 2.6) .
The formula can be formally proved using calculus: By similarity, the dimensions of a cross section parallel to the base increase linearly from the apex to the base. Then, the cross section at any heighty is the base scaled by a factor of 1 - \tfrac{y}{h}, where h is the height from the base to the apex. Since the area of any shape is multiplied by the square of the shape's scaling factor, the area of a cross section at height y is \frac{B(h - y)^2}{h^2}. The volume is given by the integral
\frac{B}{h^2} \int_0^h (h-y)^2 \, dy = \frac{-B}{3h^2} (h-y)^3 \bigg|_0^h = \tfrac{1}{3}Bh.
The volume of a pyramid whose base is an n-sided regular polygon with side length s and whose height is h is therefore:
V = \frac{n}{12}hs^2 \cot\frac{\pi}{n}.
The volume of a pyramid whose base is a regular n-sided polygon with radius R is therefore:
V = \frac{nR^2h}{6} \sin{\frac{2\pi}{n}}.
The same equation, V= \tfrac{1}{3}Bh, also holds for cones with any base (not necessarily a polyhedron). This can be proven by the same argument as above, or, for sufficiently simple cones, by approximating the cone by pyramids; 
The surface area of a pyramid is A= B + \frac{PL}{2} where B is the base area, P is the base perimeter and L is the slant height: L= \sqrt{h^2+r^2} where h is the pyramid altitude and r is the inradius of the base.

class Pyramid{
     String name;
     double a=2;
     double h=4;
 void calculate(){
  System.out.println(a*a+(a*h*2));
 }
 void calculate1(){
  System.out.println((a*a*h)/3);
 }
}
class CalPy{
 public static void main(String args[]){
  Pyramid p1=new Pyramid();
  p1.name="Pyramid-Area";
  System.out.println(p1.name);
  p1.calculate();

 Pyramid p2=new Pyramid();
  p2.name="Pyramid-Volume";
  System.out.println(p2.name);
  p2.calculate1();
    }
}

0 comments:

Post a Comment

Powered by Blogger.