de.steeringbehaviors.simulation.renderer
Class Rect

java.lang.Object
  extended by de.steeringbehaviors.simulation.renderer.Rect

public class Rect
extends java.lang.Object

class Rectangle Implements a simple rectangle based on Point2d objects


Field Summary
protected  Point2d m_p1
          Upper left point of the rectangle
protected  Point2d m_p2
          Lower right point of the rectangle
 
Constructor Summary
Rect()
          Constructor
Rect(double x1, double y1, double x2, double y2)
          Constructor
Rect(Point2d p, double width, double height)
          Constructor
Rect(Point2d p1, Point2d p2)
          Constructor
 
Method Summary
 double getHeight()
          Returns the height of the rectangle
 Point2d getp1()
          Returns the upper left point of the rectangle
 Point2d getp2()
          Returns the lower right point of the rectangle
 double getWidth()
          Returns the width of the rectangle
 boolean inRect(Point2d p)
          Tests, if a point is inside the rectangle
 void setp1(Point2d p1)
          Sets the upper left point of the rectangle
 void setp2(Point2d p2)
          Sets the lower right point of the rectangle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_p1

protected Point2d m_p1
Upper left point of the rectangle


m_p2

protected Point2d m_p2
Lower right point of the rectangle

Constructor Detail

Rect

public Rect()
Constructor


Rect

public Rect(Point2d p1,
            Point2d p2)
Constructor

Parameters:
p1 - Upper left point
p2 - Lower right point

Rect

public Rect(double x1,
            double y1,
            double x2,
            double y2)
Constructor

Parameters:
x1 - Upper left point x position
y1 - Upper left point y position
x2 - Lower right point x position
y2 - Lower right point y position

Rect

public Rect(Point2d p,
            double width,
            double height)
Constructor

Parameters:
p - Upper left point
width - Width of the rectangle
height - Height of the rectangle
Method Detail

setp1

public void setp1(Point2d p1)
Sets the upper left point of the rectangle

Parameters:
p1 - Upper left point

setp2

public void setp2(Point2d p2)
Sets the lower right point of the rectangle

Parameters:
p2 - Lower right point

getp1

public Point2d getp1()
Returns the upper left point of the rectangle

Returns:
Upper left point

getp2

public Point2d getp2()
Returns the lower right point of the rectangle

Returns:
Lower right point

getWidth

public double getWidth()
Returns the width of the rectangle

Returns:
The width

getHeight

public double getHeight()
Returns the height of the rectangle

Returns:
The height

inRect

public boolean inRect(Point2d p)
Tests, if a point is inside the rectangle

Parameters:
p - Point to test
Returns:
True / False