/** * Ein bestehender Punkt wird geaendert. * * @param index Stelle an der der Punkt geändert werden soll * @param punkt Punkt mit neuen Koordinaten * @throws IndexOutOfBoundsException if the index is out of range (index < 0 || index >= size()) */ public void punktAendern(int index, Punkt punkt) throws IndexOutOfBoundsException { punkte.get(index).setX(punkt.getX()); punkte.get(index).setY(punkt.getY()); // alternativ, waere aber kein aendern sondern ersetzten // punkte.set(index, punkt); setChanged(); notifyObservers(punkt); }
/* ***************************************************** * Skala upp (ned) en punkt. Vektorn från p0 till p1 * förlängs enligt en faktor (kan vara <1) och en ny * punkt beräknas. ***************************************************** */ protected Punkt Skala(Punkt p0, Punkt p1, double faktor) { double r, phi; double x0, y0, x1, y1, x2, y2; double dx, dy; x0 = p0.GetX(); y0 = p0.GetY(); x1 = p1.GetX(); y1 = p1.GetY(); dx = x1 - x0; dy = y1 - y0; r = Math.sqrt(dx * dx + dy * dy); phi = Math.atan2(dx, dy); x2 = x0 + faktor * r * Math.sin(phi); y2 = y0 + faktor * r * Math.cos(phi); return new Punkt(x2, y2); }
public Ruch(Punkt a, RuchomyTwor b, Wektor c) { punktKoncowy = a; obiekt = b; przemieszczenie = c; Punkt punkt = obiekt.getPozycjaNaSzachownicy(); punkt.x += przemieszczenie.x; punkt.y += przemieszczenie.y; if (obiekt instanceof Istota) { Istota istota = (Istota) obiekt; istota.setwRuchu(true); if (przemieszczenie.x > 0) istota.setwPrawo(true); if (przemieszczenie.x < 0) istota.setwPrawo(false); } }
/* ***************************************************** * Förflytta punkten p med kvantiteten x resp y ***************************************************** */ protected Punkt Translatera(Punkt p, int x, int y) { return new Punkt(p.GetX() + x, p.GetY() + y); }