EOS 2  1.1.0
Einfache Objektbasierte Sprache
Rectangle.java
gehe zur Dokumentation dieser Datei
1 package de.lathanda.eos.game.geom;
2 
3 import de.lathanda.eos.base.math.Point;
4 import de.lathanda.eos.base.math.Vector;
5 
17 public class Rectangle extends Polygon {
18 
22  protected Rectangle() {
23  super();
24  }
25 
33  public Rectangle(Point z, double width, double height) {
34  this(width, height);
35  moveTo(z);
36  }
37 
44  public Rectangle(double width, double height) {
45  super(new double[]{-width / 2, -width / 2, width / 2, width / 2},
46  new double[]{-height / 2, height / 2, height / 2, -height / 2});
47  }
48 
60  public Rectangle(double left, double bottom, double width, double height) {
61  super(new double[]{left, left, left + width, left + width},
62  new double[]{bottom, bottom + height, bottom + height, bottom});
63  }
64 
73  public Rectangle(Point a, Point b, double breadth) {
74  Vector d = new Vector(a, b).rotateRightAngleCounterClockwise().setLength(breadth / 2);
76  new double[]{a.getX() - d.getdx(), a.getX() + d.getdx(), b.getX() + d.getdx(), b.getX() - d.getdx()},
77  new double[]{a.getY() - d.getdy(), a.getY() + d.getdy(), b.getY() + d.getdy(), b.getY() - d.getdy()}
78  );
79  }
80 
81  /* (non-Javadoc)
82  * @see de.lathanda.sgl.geom2d.Polygon#getOutlineType()
83  */
84  protected Types getOutlineType() {
85  if (angle == 0) {
86  return Types.RECTANGLE;
87  } else {
88  return Types.POLYGON;
89  }
90  }
91 }
Vector setLength(double l)
Definition: Vector.java:209
final void setVertices(double[] x, double[] y)
Definition: Polygon.java:101
Rectangle(Point a, Point b, double breadth)
Definition: Rectangle.java:73
Rectangle(double left, double bottom, double width, double height)
Definition: Rectangle.java:60
Rectangle(Point z, double width, double height)
Definition: Rectangle.java:33
Rectangle(double width, double height)
Definition: Rectangle.java:44
double angle
Drehwinkel.
Definition: Shape.java:59
double bottom
Untere Grenze.
Definition: Shape.java:47
double left
Linke Grenze.
Definition: Shape.java:43
void moveTo(double x, double y)
Definition: Shape.java:291
Impressum