Rechtwinkligs Dreieck
Dieses Script berechnet ein rechtwinkliges Dreieck und gibt
dieses grafisch aus
|
Script: |
<?php
$a=300;
$b=200;
$c=round(sqrt(pow($a,2)+pow($b,2)));
$alpha=round(rad2deg(asin($a/$c)));
$beta=round(rad2deg(asin($b/$c)));
$gamma=90;
$p=round(pow($a,2)/$c);
$q=round(pow($b,2)/$c);
$h=round(sqrt($p*$q));
$img=imagecreate($c+80,$h+40);
$bg=imagecolorallocate($img,255,255,255);
$black=imagecolorallocate($img,0,0,0);
$punkte = array(0, $h, $c, $h, $q, 0);
$anzahl = count($punkte) / 2;
imagepolygon($img, $punkte, $anzahl, $black);
imageline($img,$q,0,$q,$h,$black);
imagestring($img,3,0+3,$h+3,"Alpha= $alpha °",$black);
imagestring($img,3,$c+3,$h+3,"Beta= $beta °",$black);
imagestring($img,3,$q+3,3,"Gamma= $gamma °",$black);
imagestring($img,3,($p/2)+$q+10,($h/2),"a= $a p",$black);
imagestring($img,3,($q/2)+10,($h/2),"b= $b p",$black);
imagestring($img,3,$c/2,$h+3,"c= $c p",$black);
imagestring($img,3,$q/2,$h+15,"q= $q p",$black);
imagestring($img,3,$q+($p/2),$h+15,"p= $p p",$black);
imagestring($img,3,$q+10,$h/2+12,"h= $h p",$black);
header("Content-Type: image/png");
imagepng($img);
?>
|
|