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['p'])) {
$p=$_GET['p'];
if (($p < -32767.9999)OR($p > 32767.9999) ){
$p=mt_rand(100,400);
}
} else {
$p=mt_rand(100,400);
}
if(isset($_GET['e'])) {
$e=$_GET['e'];
if (($e < 0)OR($e >=1) ){
$e=mt_rand(0,900)/1000;
}
} else {
$e=mt_rand(0,900)/1000;
}
if(isset($_GET['fx'])) {
$fx=$_GET['fx'];
if (($fx < -32767.9999)OR($fx > 32767.9999) ){
$fx=mt_rand(-600,600);
}
} else {
$fx=mt_rand(-600,600);
}
if(isset($_GET['fy'])) {
$fy=$_GET['fy'];
if (($fy < -32767.9999)OR($fy > 32767.9999) ){
$fy=mt_rand(-600,600);
}
} else {
$fy=mt_rand(-600,600);
}
# Auswertung beginnen:
# (start evaluation)
$p=abs($p);
$e=abs($e);
$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);
$h1=1-$e*$e;
$rx=round($p/$h1,$runden);
$ry=round($p/sqrt($h1),$runden);
$cc=$rx*$e;
$cx=round($fx-$ca*$cc,$runden);
$cy=round($fy-$sa*$cc,$runden);
$cpi=cos($theta);
$spi=sin($theta);
$rh=1+$e*$cpi;
$rhd=-$e*$spi;
$r=$p/$rh;
$xx=$r*$cpi;
$yy=$r*$spi;
$x1=$ca*$xx-$sa*$yy+$fx;
$y1=$sa*$xx+$ca*$yy+$fy;
$cpi=cos($theta+$delta);
$spi=sin($theta+$delta);
$rh=1+$e*$cpi;
$rhd=-$e*$spi;
$r=$p/$rh;
$xx=$r*$cpi;
$yy=$r*$spi;
$x2=$ca*$xx-$sa*$yy+$fx;
$y2=$sa*$xx+$ca*$yy+$fy;
$xt1=$ca*($x1-$cx) + $sa*($y1-$cy);
$yt1=-$sa*($x1-$cx) + $ca*($y1-$cy);
$xt2=$ca*($x2-$cx) + $sa*($y2-$cy);
$yt2=-$sa*($x2-$cx) + $ca*($y2-$cy);
$th1=$xt1/$rx;
$th2=$yt1/$ry;
$th3=$xt2/$rx;
$th4=$yt2/$ry;
if($yt1>=0) {
$vh=1;
} else {
$vh=-1;
}
if($yt2>=0) {
$vg=1;
} else {
$vg=-1;
}
if ($deltadeg>0) {
$fS = 1;
} else {
$fS = 0;
}
$theta1=fmod($vh*acos($th1/sqrt($th1*$th1+$th2*$th2))/M_PI*180+360,360);
$theta2=fmod($vg*acos($th3/sqrt($th3*$th3+$th4*$th4))/M_PI*180+360,360);
# Differenzwinkel
# (difference angle)
$dtheta=$theta2-$theta1;
if (($fS==1) AND ($dtheta<0)){
$dtheta=$dtheta+360;
} elseif (($fS==0) AND ($dtheta>0)) {
$dtheta=$dtheta-360;
}
if (abs($dtheta) >180) {
$fA=1;
} else {
$fA=0;
}
$x1=round($x1,$runden);
$y1=round($y1,$runden);
$x2=round($x2,$runden);
$y2=round($y2,$runden);
$rx=round($rx,$runden);
$ry=round($ry,$runden);
$theta1=round($theta1,$runden);
$theta2=round($theta2,$runden);
$dtheta=round($dtheta,$runden);
# 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";
}
#################################
# Datensatz erzeugen / Interpolation
$dphi=$delta/$anz;
for ($j = 0; $j <= $anz; $j++) {
$tt=$dphi*$j;
$cpi=cos($tt+$theta);
$spi=sin($tt+$theta);
$rh=1+$e*$cpi;
$rhd=-$e*$spi;
$r=$p/$rh;
# Punkte / points
$xx=$r*$cpi;
$yy=$r*$spi;
# Ableitungen / derivatives ...
$dx=$dphi*(-$r*$spi-$cpi*$p*$rhd/$rh/$rh);
$dy=$dphi*($r*$cpi-$spi*$p*$rhd/$rh/$rh);
# rotieren / rotate
$data[$j][0]=$ca*$xx-$sa*$yy+$fx;
$data[$j][1]=$sa*$xx+$ca*$yy+$fy;
$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";
$pl=' \n";
for ($j = 2; $j <=$anz; $j++) {
$pfada.=$cq[$j][0].' '.$cq[$j][1].' '.$data[$j][0].' '.$data[$j][1]."\n";
$pl.='\n";
}
###################################
$aus="
Komplette Ellipse / Complete Ellipse
";
if ($flag2) {
$aus.="
Approximierter Pfad / Approximated Path
Pfad / Path
Ellipsenfokus / ellipse focus
Ellipsenzentrum / ellipse centre
Anfangspunkt / initial point
Endpunkt / final point
Interpolationspunkte mit gleichem Winkelabstand / interpolation points with the same angle distance
$pl
";
}
# viewBox berechnen / calculate viewBox
$vv=max(4*ceil(0.6*$p/(1-$e)),400);
$vh=1.5*$vv;
$vy=round($fy-$vv/1.85);
$vx=round($fx-$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;
$texty=$vy +2+$lh;
$text2=$vy +2+2*$lh;
$text3=$vy +2+3*$lh;
$aus.="
fx = $fx | fy = $fy | p = $p | e = $e | phi = $phideg | theta = $thetadeg | delta = $deltadeg | anz = $anz | rnd = $runden
Aktuelle Werte / Current Values
cx = $cx | cy = $cy | rx = $rx | ry = $ry | theta = $theta1 | dtheta = $dtheta | phi = $phideg
Zentrische Parameter / centric parameters
$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
?>