myGully.com

myGully.com (https://mygully.com/index.php)
-   Programmierung (https://mygully.com/forumdisplay.php?f=67)
-   -   Java Programmierung Bounding Box (https://mygully.com/showthread.php?t=2914803)

Sherry321 30.04.13 11:24

Java Programmierung Bounding Box
 
Hallo,

ich hab ein Array von Punkten erstellt und möchte aus dieser Punktmenge eine umgebende BoundingBox ermitteln. Dabei soll die kleinste und zum anderen die größte
Punktkoordinate die BoundingBox liefern. Also über ein Schleife. Ich weiß leider da ich nur absolutre Anfänger bin nicht wie ich so eine Schleife schreiben kann. Mein jetziger Code sieht wie folgt aus:
Zitat:

Hauptklasse:public class BoundingBox {

public static void main (String[] args) {
Point p1 = new Point(1.0,1.0);
Point p2 = new Point(2.0,3.0);
Point p3 = new Point(5.0,2.0);


System.out.println("Das Array beinhaltet die Punkte: (" + p1.getvx() + "," + p1.getvy() + ") (" + p2.getvx() + "," + p2.getvy() + ") (" + p3.getvx() + "," + p3.getvy() + ")");
// System.out.println("Die BoundingBox hat die Höhe 2 und die Breite 4") ;

// System.out.println("");
// System.out.println("");
}

}

Nebenklasse:
public class Point {
double x;
double y;


public Point (double vx, double vy) {
this.x = vx;
this.y = vy;
}

public double getvx() {
return x;
}
public double getvy() {
return y;
}
}

Kann mir vllt jmd helfen?
Gruß Sherry

germgerm 30.04.13 13:27

Zitat:

ich hab ein Array von Punkten erstellt
Wo ist dein Array?

raid4x 27.05.13 20:57

falls ich richtig verstanden habe, dann du braucht zu erste einen Array von Type Point:

Point [] feld = new Point [3];

danach packst du alle Points rein:


feld[0] = p1;
feld[1] = p2;
feld[3] = p3;



jetzt hst du Array, über position feld[0], feld[1] und feld[2] kannst du auf Inhalt zugreifen
usw....


Alle Zeitangaben in WEZ +1. Es ist jetzt 16:44 Uhr.

Powered by vBulletin® (Deutsch)
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.