\n"; $pfad1="M 0, 0 "; $poly="0 0 "; $xalt=0; $yalt=0; for ($i = 1; $i <= $anz; $i++) { $x=$i*900/$anz; $y=-400*sin(2.0*M_PI*$i/$anz); $kx=($i-0.5)*900/$anz; $ky=-400*sin(2.0*M_PI*($i-0.5)/$anz); $kpx= 2*$kx- 0.5*($xalt + $x); $kpy= 2*$ky- 0.5*($yalt + $y); # das Runden fuer die Ausgabe ist wichtig, # damit die svg-Ausgabe nicht # unnoetig gross wird... $px=round($x,1); $py=round($y,1); $pkx=round($kpx,1); $pky=round($kpy,1); $pax=round($xalt,1); $pay=round($yalt,1); # alte Werte ungerundet aufheben, # denn die werden beim naechsten Umlauf # noch gebraucht... $xalt=$x; $yalt=$y; $einzelpunkte .="\n"; $pfad1 .="Q $pkx,$pky $px,$py \n"; $poly .="$px,$py \n"; } # erneuter Umlauf mit 100 Stuetzstellen $anz=100; $pfad2="M 0, 0 "; $xalt=0; $yalt=0; for ($i = 1; $i <= $anz; $i++) { $x=$i*900/$anz; $y=-400*sin(2.0*M_PI*$i/$anz); $kx=($i-0.5)*900/$anz; $ky=-400*sin(2.0*M_PI*($i-0.5)/$anz); $kpx= 2*$kx- 0.5*($xalt + $x); $kpy= 2*$ky- 0.5*($yalt + $y); $px=round($x,1); $py=round($y,1); $pkx=round($kpx,1); $pky=round($kpy,1); $pax=round($xalt,1); $pay=round($yalt,1); $xalt=$x; $yalt=$y; $pfad2 .="Q $pkx,$pky $px,$py \n"; } # svg-header senden: $content="Content-type: image/svg+xml"; header($content); # xml-Zeile ausgeben echo ""; # und jetzt das Dokument ?> Sinus mit quadratischer Bezierkurve genähert Zwar nicht stetig differenzierbar, aber optisch schon sehr ähnlich wirkende Näherung des Sinus mit einer Bezierkurve. Nullpunkt festlegen, Linienzug, Pfad und Einzelpunkte ausgeben.