100) ){ $anz=6; } } else { $anz=6; } # runden auf wieviel Stellen / rounding to how many digits if(isset($_GET['rnd'])) { $runden=$_GET['rnd']; if (($runden < 0)OR($runden > 4) ){ $runden=2; } } else { $runden=2; } # Parameter ... if(isset($_GET['phi'])) { $phideg=$_GET['phi']; if (($phideg < -32767.9999)OR($phideg > 32767.9999) ){ $phideg=mt_rand(-1000,1000); } } else { $phideg=mt_rand(-1000,1000); } if(isset($_GET['theta'])) { $thetadeg=$_GET['theta']; if (($thetadeg < -32767.9999)OR($thetadeg > 32767.9999) ){ $thetadeg=mt_rand(-1000,1000); } } else { $thetadeg=mt_rand(-1000,1000); } if(isset($_GET['delta'])) { $deltadeg=$_GET['delta']; if (($deltadeg < -32767.9999)OR($deltadeg > 32767.9999) ){ $deltadeg=mt_rand(-1000,1000); } } else { $deltadeg=mt_rand(-1000,1000); } if(isset($_GET['rx'])) { $rx=$_GET['rx']; if (($rx < -32767.9999)OR($rx > 32767.9999) ){ $rx=mt_rand(-300,300); } } else { $rx=mt_rand(-300,300); } if(isset($_GET['ry'])) { $ry=$_GET['ry']; if (($ry < -32767.9999)OR($ry >32767.9999) ){ $ry=mt_rand(-300,300); } } else { $ry=mt_rand(-300,300); } if(isset($_GET['cx'])) { $cx=$_GET['cx']; if (($cx < -32767.9999)OR($cx > 32767.9999) ){ $cx=mt_rand(-600,600); } } else { $cx=mt_rand(-600,600); } if(isset($_GET['cy'])) { $cy=$_GET['cy']; if (($cy < -32767.9999)OR($cy > 32767.9999) ){ $cy=mt_rand(-600,600); } } else { $cy=mt_rand(-600,600); } # Auswertung beginnen: # (start evaluation) $rx=abs($rx); $ry=abs($ry); $phideg=fmod($phideg,360); $thetadeg=fmod($thetadeg,360); $deltadeg=fmod($deltadeg,360); $phi=$phideg*M_PI/180; $theta=$thetadeg*M_PI/180; $delta=$deltadeg*M_PI/180; $ca=cos($phi); $sa=sin($phi); $xh1=$rx*cos($theta); $yh1=$ry*sin($theta); $xh2=$rx*cos($theta+$delta); $yh2=$ry*sin($theta+$delta); $x1=round($ca*$xh1-$sa*$yh1+$cx,$runden); $y1=round($sa*$xh1+$ca*$yh1+$cy,$runden); $x2=round($ca*$xh2-$sa*$yh2+$cx,$runden); $y2=round($sa*$xh2+$ca*$yh2+$cy,$runden); if (abs($deltadeg)>180) { $fA = 1; } else { $fA = 0; } if ($deltadeg>0) { $fS = 1; } else { $fS = 0; } # darstellen oder nicht? # to present or not? $flag1=($rx*$ry>0); $flag2=(!(($x1==$x2) AND ($y1==$y2))); $flag= ($flag1 AND $flag2); $pfad='Kein Pfad / no path'; if ($flag) { $pfad="M$x1,$y1 A$rx,$ry $phideg $fA,$fS $x2,$y2"; } elseif ($flag2) { $pfad="M$x1,$y1 L$x2,$y2"; $pfada="M$x1,$y1 L$x2,$y2"; } $aus=''; if ($flag) { ################################# # Datensatz erzeugen / Interpolation $dphi=$delta/$anz; for ($j = 0; $j <= $anz; $j++) { $tt=$dphi*$j; $cpi=cos($tt+$theta); $spi=sin($tt+$theta); # Punkte / points $xx=$rx*$cpi; $yy=$ry*$spi; # Ableitungen / derivatives ... $dx=-$dphi*$rx*$spi; $dy=$dphi*$ry*$cpi; # rotieren / rotate $data[$j][0]=$ca*$xx-$sa*$yy+$cx; $data[$j][1]=$sa*$xx+$ca*$yy+$cy; $data[$j][2]=$ca*$dx-$sa*$dy; $data[$j][3]=$sa*$dx+$ca*$dy; } # Aus den Ableitungen die Kontrollpunkte berechnen # (generate control points from derivatives) $cp[0][0]=round($data[0][0]+$data[0][2]/3,$runden); $cp[0][1]=round($data[0][1]+$data[0][3]/3,$runden); for ($j = 0; $j <= $anz; $j++) { $cq[$j][0]=round($data[$j][0]-$data[$j][2]/3,$runden); $cq[$j][1]=round($data[$j][1]-$data[$j][3]/3,$runden); # und nun erst Punkte runden / and now round points $data[$j][0]=round($data[$j][0],$runden); $data[$j][1]=round($data[$j][1],$runden); } # Daraus Pfad bestimmen und malen der Punkte vorbereiten # (generate path data and prepare for painting) $pfada='M'.$data[0][0].' '.$data[0][1].' C'.$cp[0][0].' '.$cp[0][1].' '.$cq[1][0].' '.$cq[1][1].' '.$data[1][0].' '.$data[1][1]." S\n"; for ($j = 2; $j <=$anz; $j++) { $pfada.=$cq[$j][0].' '.$cq[$j][1].' '.$data[$j][0].' '.$data[$j][1]."\n"; } ################################### } $ppx=$rx; $ppy=0; $px=round($ca*$ppx-$sa*$ppy+$cx,$runden); $py=round($sa*$ppx+$ca*$ppy+$cy,$runden); $aus=" Komplette Ellipse / Complete Ellipse Approximierter Pfad / Approximated Path Pfad / Path x-Hauptachsen-Markierung / x-major-axis marker Ellipsenzentrum / ellipse centre Anfangspunkt / initial point Endpunkt / final point Hauptachsen der Ellipse / major axes of the ellipse "; # viewBox berechnen / calculate viewBox $vv=max(4*ceil(0.6*max($rx,$ry)),400); $vh=1.5*$vv; $vy=round($cy-$vv/1.85); $vx=round($cx-$vh/2); $viewBox="$vx $vy $vh $vv"; # Text skalieren und formatieren: # (scale and format text) $fs=ceil($vv/40); $lh=ceil(1.2*$vv/40); $textx=$vx +4; $texty1=$vy +2+$lh; $texty2=$vy +2+2*$lh; $texty3=$vy +2+3*$lh; $texty4=$vy +2+4*$lh; $aus.=" GET: cx, cy, rx, ry, phi, theta, delta, anz, rnd Ellipsenbogen Eingabeparameter / Elliptical Arc Input parameters cx,cy: Zentrum der Ellipse / centre of the ellipse rx,ry: Große und Kleine halbe Hauptachse / large and small semi major axis phi: Drehwinkel in Grad von der x-Achse zur Großen Hauptachse / rotation angle in degree from x-axis to the major axis theta: Startwinkel in Grad / initial angle in degree delta: Differenzwinkel zum Malen / difference angle for painting anz: Anzahl der Interpolationspunkte für die Näherung (grün), Bereich: 2 - 100, Voreinstellung 6 / number of interpolation points for the approximation (green), range: 2 -100 rnd: Anzahl der Stellen, auf die gerundet wird, Bereich: 0 - 4, Voreinstellung 2 / number of digits to be rounded in the fractional part, range 0 - 4, default 2 ?cx=$cx&cy=$cy&rx=$rx&ry=$ry&phi=$phideg&theta=$thetadeg&delta=$deltadeg&anz=$anz&rnd=$runden Aktuelle Werte / Current Values M x1,y1 A rx,ry phi fA,fS x2,y2 Pfadnotation / Path Notation $pfad Pfad / Path "; # svg-header senden: $content="Content-type: image/svg+xml; charset=iso-8859-1"; header($content); # xml-Zeile ausgeben echo ""; # und jetzt das Dokument ?> SVG: Pfadfragment für Ellipsenbogen bestimmen / Determine Elliptical Arc Path Fragment Nach Angabe von GET-Parametern wird ein elliptischer Bogen als SVG Kommando ermittelt und dargestellt. Siehe Titel und Beschreibung der Texte in der Graphik für Details. Due to given GET parameters an elliptic arc is determined as SVG command and painted. For details see title and description of the texts inside the graphics.