Mittelpunkt von Rechteck berechnen PHP

Status
Für weitere Antworten geschlossen.

nischtak

Banned
Registriert
Nov. 2005
Beiträge
692
hallo zusammen!!!

meine aufgabe:
Erweitere das programm so, das bei der Eingabe eines Punktes die entferung zum Mittelpunkt jedes rechtecks berechnet und in der Tabelle unterhalb des rechtecks angezeigt wird

Okay tabele und eingabe habe ich schon hier mein skript
PHP:
echo "<form action=\"rechteck.php\" method=\"post\">";
echo "Bitte Kooardinate eingeben <br> max 800x600 <br>";
echo "<table>";
echo "<tr><td>X-Achse <input type=\"text\" size=\"17\" name=\"x\">";
echo "<tr><td>Y-Achse <input type=\"text\" size=\"17\" name=\"y\">";
echo "<tr><td><input type=\"submit\" value=\"ANZEIGEN\">";
echo "</table>";
echo "</form>";


 {
$x = $_POST['x'];
$y = $_POST['y'];

ImageString($im,5,$x,$y,"X","$black");

if ($x > 800 or $y > 600)
 {
 echo "Die eingebenen Kooardinaten $x/$y liegen ausserhalb des Bildes";
 }    
   else
   {
   echo "Die Koordinate $x/$y liegt in :<br><br><table>";
   for ($i = 0; $i < count($cor); $i++)
   {
   $sign = 'NEIN';
   $array = $cor [$i];
   if ($x >= $array[0] && $x <= $array[2] && $y >= $array[1] && $y <= $array[3])
    {
     $sign = 'Ja';
    }
    echo "<tr><td>Rechteck $array[0]:<td>$sign";
    }
    echo "</table>";
   $test=array($x,$y);
   return $test;
  }
 }
und hier meine tabelle

PHP:
function draw_table ($cor)
{
echo "<table border>";

echo "<tr><th>x1<th>y1<th>x2<th>y2<th>x3<th>y3<th>x4<th>y4<th>Mittelp. $test[0]/$test[1]</tr>";
for ($i = 0; $i < count ($cor); $i++)
 {
  if ($test[0] != NULL && $test[1] != NULL)
  {
   $ent = length($cor,$test, $i);
  }
  else
  {
   $ent = '--';
  }

$array = ($cor [$i]);
    
echo "<tr><td>$array[0]px
	  <td>$array[1]px
          <td>$array[2]px 
          <td>$array[3]px
          <td>$array[4]px
          <td>$array[5]px
          <td>$array[6]px
          <td>$array[7]px
	  <td>$mittelpunkt";
}

echo "</table>";
}

und etwas genauer jetz
ich hab ein bild mit 4 rechtecken, ich muss eine kooardinate eingeben können in das bild, und dei eingebene Kooardinate soll mir dann die entfernung zu jedem mittelpunkt von einem rechteck zeigen
 
Da das hier aber kein Hausaufgabenboard ist, ist hier schluss. Nur mal so als Tipp: Der Mittelpunkt eines Rechtecks liegt auf der Hälfte jeder Seitenkante, der waagerechten, und der senkrechten. Das muss reichen. ;)
Am besten mal aufmalen mitsamt Koordinatensystem, und dann mal scharf nachdenken.
 
Status
Für weitere Antworten geschlossen.
Zurück
Oben