rss
Twitter Delicious Facebook Digg Stumbleupon Favorites
Showing posts with label area. Show all posts
Showing posts with label area. Show all posts

Friday, October 7, 2011

Find the area and volume of a sphere

A sphere is a perfectly round geometrical object in three-dimensional space, such as the shape of a round ball. Like a circle in two dimensions, a perfect sphere is completely symmetrical around its center, with all points on the surface lying the same distance r from the center point. This distance r is known as the radius of the sphere. The maximum straight distance through the sphere is known as the diameter of the sphere. It passes through the center and is thus twice the radius.
In higher mathematics, a careful distinction is made between the sphere (a two-dimensional spherical surface embedded in three-dimensional Euclidean space) and the ball (the three-dimensional shape consisting of a sphere and its interior).
In 3 dimensions, the volume inside a sphere (that is, the volume of a ball) is given by the formula
\!V = \frac{4}{3}\pi r^3
where r is the radius of the sphere and π is the constant pi. This formula was first derived by Archimedes, who showed that the volume of a sphere is 2/3 that of a circumscribed cylinder. (This assertion follows from Cavalieri's principle.) In modern mathematics, this formula can be derived using integral calculus, e.g.disk integration to sum the volumes of an infinite number of circular disks of infinitesimal thickness stacked centered side by side along the x axis from x = 0where the disk has radius r (i.e. y = r) to x = r where the disk has radius 0 (i.e. y = 0).
At any given x, the incremental volume (δV) is given by the product of the cross-sectional area of the disk at x and its thickness (δx):
\!\delta V \approx \pi y^2 \cdot \delta x.
The total volume is the summation of all incremental volumes:
\!V \approx \sum \pi y^2 \cdot \delta x.
In the limit as δx approaches zero this becomes:
\!V = \int_{-r}^{r} \pi y^2 dx.
At any given x, a right-angled triangle connects x, y and r to the origin, hence it follows from Pythagorean theorem that:
\!r^2 = x^2 + y^2.
Thus, substituting y with a function of x gives:
\!V = \int_{-r}^{r} \pi (r^2 - x^2)dx.
This can now be evaluated:
\!V = \pi \left[r^2x - \frac{x^3}{3} \right]_{-r}^{r} = \pi \left(r^3 - \frac{r^3}{3} \right) - \pi \left(-r^3 + \frac{r^3}{3} \right) = \frac{4}{3}\pi r^3.
Therefore the volume of a sphere is:
\!V = \frac{4}{3}\pi r^3.
Alternatively this formula is found using spherical coordinates, with volume element
\mathrm{d}V=r^2\sin\theta\,\mathrm{d}r\,\mathrm{d}\theta\,\mathrm{d}\varphi
In higher dimensions, the sphere (or hypersphere) is usually called an n-ball. General recursive formulas exist for deriving the volume of an n-ball.
For most practical uses, the volume of a sphere can be approximated as 52.4% of the volume of an inscribing cube, since \pi/6 \approx 0.5236. For example, since a cube with edge length 1 m has a volume of 1 m3, a sphere with diameter 1 m has a volume of about 0.524 m3.
The surface area of a sphere is given by the following formula
\!A = 4\pi r^2.
This formula was first derived by Archimedes, based upon the fact that the projection to the lateral surface of a circumscribing cylinder (i.e. the Lambert cylindrical equal-area projection) is area-preserving. It is also the derivative of the formula for the volume with respect to r because the total volume of a sphere of radius r can be thought of as the summation of the surface area of an infinite number of spherical shells of infinitesimal thickness concentrically stacked inside one another from radius 0 to radius r. At infinitesimal thickness the discrepancy between the inner and outer surface area of any given shell is infinitesimal and the elemental volume at radius r is simply the product of the surface area at radius r and the infinitesimal thickness.
At any given radius r, the incremental volume (δV) is given by the product of the surface area at radius r (A(r)) and the thickness of a shell (δr):
\delta V \approx A(r) \cdot \delta r. \,
The total volume is the summation of all shell volumes:
V \approx \sum A(r) \cdot \delta r.
In the limit as δr approaches zero this becomes:
V = \int_0^r A(r) \, dr.
Since we have already proved what the volume is, we can substitute V:
\frac{4}{3}\pi r^3 = \int_0^r A(r) \, dr.
Differentiating both sides of this equation with respect to r yields A as a function of r:
\!4\pi r^2 = A(r).
Which is generally abbreviated as:
\!A = 4\pi r^2.
Alternatively, the area element on the sphere is given in spherical coordinates by dA = r^2 \sin\theta\, d\theta\, d\phi.. With Cartesian coordinates, the area element dS=\frac{r}{\sqrt{r^{2}-\sum_{i\ne k}x_{i}^{2}}}\Pi_{i\ne k}dx_{i},\;\forall k. More generally, see area element.
The total area can thus be obtained by integration:
A = \int_0^{2\pi} \int_0^\pi r^2 \sin\theta \, d\theta \, d\phi = 4\pi r^2.


class Sphere{
 String name;
     double p=3.141592654;
     double r=4;
     double h=5;
     double l=6;
 void calculate(){
  System.out.println(4*p*r*r);
 }
 void calculate1(){
  System.out.println((p*r*r*r)*4/3);
 }
}
class CalS{
 public static void main(String args[]){
  Sphere s1=new Sphere();
  s1.name="Sphere-Area";
  System.out.println(s1.name);
  s1.calculate();

 Sphere s2=new Sphere();
  s2.name="Sphere-Volume";
  System.out.println(s2.name);
  s2.calculate1();
    }
}

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();
    }
}

Find the area and volume of a prism

In geometry, a prism is a polyhedron with an n-sided polygonal base, a translated copy (not in the same plane as the first), and n other faces (necessarily all parallelograms) joining corresponding sides of the two bases. All cross-sections parallel to the base faces are the same. Prisms are named for their base, so a prism with a pentagonal base is called a pentagonal prism. The prisms are a subclass of the prismatoids.


class Prism{
 String name;
     double a=2;
     double r=4;
     double h=5;
     double l=6;
 void calculate(){
  System.out.println(3*a*l+a*h);
 }
 void calculate1(){
  System.out.println((a*h*l)/2);
 }
}
class CalPr{
 public static void main(String args[]){
  Prism pr1=new Prism();
  pr1.name="Prism-Area";
  System.out.println(pr1.name);
  pr1.calculate();

 Prism pr2=new Prism();
  pr2.name="Prism-Volume";
  System.out.println(pr2.name);
  pr2.calculate1();
    }
}

Find the area and volume of a cylinder

A cylinder is one of the most basic curvilinear geometric shapes, the surface formed by the points at a fixed distance from a given line segment, the axis of the cylinder. The solid enclosed by this surface and by two planes perpendicular to the axis is also called a cylinder. The surface area and the volume of a cylinder have been known since deep antiquity.
In differential geometry, a cylinder is defined more broadly as any ruled surface spanned by a one-parameter family of parallel lines. A cylinder whose cross section is an ellipse, parabola, or hyperbola is called an elliptic cylinder, parabolic cylinder, or hyperbolic cylinder respectively.
In common use a cylinder is taken to mean a finite section of a right circular cylinder, i.e., the cylinder with the generating lines perpendicular to the bases, with its ends closed to form two circular surfaces, as in the figure (right). If the cylinder has a radius r and length (height) h, then its volume is given by

V = πr2h
and its surface area is:
  • the area of the top r2) +
  • the area of the bottom r2) +
  • the area of the side (rh).
Therefore without the top or bottom (lateral area), the surface area is:
A = 2πrh.
With the top and bottom, the surface area is:
A = 2πr2 + 2πrh = 2πr(r + h).
For a given volume, the cylinder with the smallest surface area has h = 2r. For a given surface area, the cylinder with the largest volume has h = 2r, i.e. the cylinder fits in a cube (height = diameter).

class Cylinder{
 String name;
     double p=3.141592654;
     double r=4;
     double h=5;
 void calculate(){
  System.out.println(2*p*r*h+2*p*r*r);
 }
 void calculate1(){
  System.out.println(p*r*r*h);
 }
}
class CalCy{
 public static void main(String args[]){
  Cylinder c1=new Cylinder();
  c1.name="Cylinder-Area";
  System.out.println(c1.name);
  c1.calculate();

 Cylinder c2=new Cylinder();
  c2.name="Cylinder-Volume";
  System.out.println(c2.name);
  c2.calculate1();
    }
}

Find the area and volume of a cone

A cone is a three-dimensional geometric shape that tapers smoothly from a flat, usually circular base to a point called the apex or vertex. More precisely, it is the solid figure bounded by a plane base and the surface (called the lateral surface) formed by the locus of all straight line segments joining the apex to the perimeter of the base. The term "cone" sometimes refers just to the surface of this solid figure, or just to the lateral surface.
The axis of a cone is the straight line (if any), passing through the apex, about which the lateral surface has a rotational symmetry.
In common usage in elementary geometry, cones are assumed to be right circular, where right means that the axis passes through the centre of the base (suitably defined) at right angles to its plane, and circular means that the base is a circle. Contrasted with right cones are oblique cones, in which the axis does not pass perpendicularly through the centre of the base. In general, however, the base may be any shape, and the apex may lie anywhere (though it is often assumed that the base is bounded and has nonzero area, and that the apex lies outside the plane of the base). For example, a pyramid is technically a cone with a polygonal base.
The volume V of any conic solid is one third of the product of the area B of the base and the height H (the perpendicular distance from the base to the apex).
V = \frac{1}{3} B H
In modern math, this formula can easily be computed using calculus – it is, up to scaling, the integral \int x^2 dx = \tfrac{1}{3} x^3. Without using calculus, the formula can be proven by comparing the cone to a pyramid and applying Cavalieri's principle – specifically, comparing the cone to a (vertically scaled) right square pyramid, which forms one third of a cube. This formula cannot be proven without using such infinitesimal arguments – unlike the 2-dimensional formulae for polyhedral area, though similar to the area of the circle – and hence admitted less rigorous proofs before the advent of calculus, with the ancient Greeks using the method of exhaustion. This is essentially the content of Hilbert's third problem – more precisely, not all polyhedral pyramids are scissors congruent (can be cut apart into finite pieces and rearranged into the other), and thus volume cannot be computed purely by using a decomposition argument.
For a circular cone with radius R and height H, the formula for volume becomes
 V = \int_0^H r^2 \pi dh
where r is the radius of the cone at height h:
 r= R \frac{h}{H}
Thus:
 V = \int_0^H [R \frac{h}{H}]^2 \pi dh
Thus:
V = \frac{1}{3} \pi R^2 H.
For a right circular cone, the surface area A is
A =\pi R^2 + \pi R S\,   where   S = \sqrt{R^2 + H^2}   is the slant height.
The first term in the area formula, πR2, is the area of the base, while the second term, πRS, is the area of the lateral surface.
A right circular cone with height h and aperture , whose axis is the z coordinate axis and whose apex is the origin, is described parametrically as
F(s,t,u) = \left(u \tan s \cos t, u \tan s \sin t, u \right)
where s,t,u range over [0,θ), [0,2π), and [0,h], respectively.
In implicit form, the same solid is defined by the inequalities
\{ F(x,y,z) \leq 0, z\geq 0, z\leq h\},
where
F(x,y,z) = (x^2 + y^2)(\cos\theta)^2 - z^2 (\sin \theta)^2.\,
More generally, a right circular cone with vertex at the origin, axis parallel to the vector d, and aperture , is given by the implicit vector equation F(u) = 0 where
F(u) = (u \cdot d)^2 - (d \cdot d) (u \cdot u) (\cos \theta)^2   or   F(u) = u \cdot d - |d| |u| \cos \theta
where u = (x,y,z), and u \cdot d denotes the dot product.

class Cone{
 String name;
     double p=3.141592654;
     double r=4;
     double h=5;
     double l=6;
 void calculate(){
  System.out.println(p*r*l);
 }
 void calculate1(){
  System.out.println((p*r*r*h)/3);
 }
}
class CalCo{
 public static void main(String args[]){
  Cone c1=new Cone();
  c1.name="Cone-Area";
  System.out.println(c1.name);
  c1.calculate();

 Cone c2=new Cone();
  c2.name="Cone-Volume";
  System.out.println(c2.name);
  c2.calculate1();
    }

}
Powered by Blogger.