948Part VCase StudiesIt takes a little more work (Free web design)
948Part VCase StudiesIt takes a little more work and trigonometry to get the areas of the triangles. In our code, wemake the job more straightforward by drawing a line from point C to point D, and consideringonly the half of the diagram above that line then at the end, we multiply by two to get thereal area. If we say that the intersection of segments AB and CD is point E, what we eventuallycare about is the area of triangles CAE and DAE. We start by calculating the angles of triangleCDA (whose side lengths are known to us) and, by using that information, determining thelengths of CE, DE, and AE. After we know these lengths, we know the bases and heights, andthe areas of the right triangles CAE and DAE are just 1/2(base height). Listing 48-1 shows code to do this kind of area calculation. Its main public function is circle_intersection_area(), which expects as arguments the radii of two circles and thedistance between them. The simplest case is where the distance is greater than the sum ofthe radii: The circles do not touch; there is no intersection, and the answer is zero. Listing 48-1:trig.php= ($other_1 + $other_2)) || ($other_1 >= ($opposite + $other_2)) || ($other_2 >= ($other_1 + $opposite))) { die( Triangle with impossible side lengths in . angle_given_sides: $opposite, $other_1, $other_2 ); } else { $numerator = ((($other_1 * $other_1) + ($other_2 * $other_2)) - ($opposite * $opposite)); $denominator = 2 * $other_1 * $other_2; return(acos($numerator / $denominator)); } } function area_to_radius ($area) { return (sqrt ($area / M_PI)); } function circle_intersection_area ($radius_left, $radius_right, $distance) { if ($radius_right + $radius_left <= $distance) { return(0); } else { // first, we find the angle measures of a triangle54
We recommend cheap and reliable webhost to host and run your web applications: Coldfusion Web Hosting services.