|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.hedgehog.HObject
com.hedgehog.geo.GeometricObject
com.hedgehog.geo.twod.GeometricObject2D
com.hedgehog.geo.twod.shapes.Shape2D
com.hedgehog.geo.twod.shapes.Polygon2D
com.hedgehog.geo.twod.shapes.StraightEdgePolygon2D
com.hedgehog.geo.twod.shapes.ConvexStraightEdgePolygon2D
com.hedgehog.geo.twod.shapes.ConvexQuadrilateral2D
com.hedgehog.geo.twod.shapes.Rectangle2D
public class Rectangle2D
Title: Rectangle2D - models a rectangle.
Description: Models a 2D rectangle having straight edges between the vertices. Note that Rectangle2D is derived from ConvexQuadrilateral2D and as a result does not have to be axis-aligned.
It is worth noting that Rectangle2D is part of the Polygon2D hierarchy and as a result is not particularly efficient when it comes to modelling simple axis-aligned rectangles for operations such as pooint-inside tests and point/line clipping. In such cases use class AxisAlignedBox2D instead.
Copyright: Copyright (c) Hedgehog Software 2007-2009.
Company: Hedgehog Software.
| Field Summary |
|---|
| Fields inherited from class com.hedgehog.geo.twod.shapes.Polygon2D |
|---|
mVertices |
| Fields inherited from class com.hedgehog.HObject |
|---|
mID, mName |
| Constructor Summary | |
|---|---|
Rectangle2D()
Default constructor. |
|
Rectangle2D(Point2D p0,
Point2D p1,
Point2D p2,
Point2D p3)
Constructor. |
|
Rectangle2D(Rectangle2D object)
Copy constructor. |
|
Rectangle2D(java.util.Vector<Point2D> vertices)
Constructor. |
|
| Method Summary | |
|---|---|
double |
angleOfRotation(boolean degrees)
Returns the angle of rotation from the x-axis vector (1,0) and the local x'-axis. |
StraightLine2D |
bottomEdge()
Returns the bottom edge. |
Point2D |
bottomLeftVertex()
Returns the (minx,miny) point. |
Point2D |
bottomRightVertex()
The bottom right vertex. |
java.util.Vector<Point2D> |
bottomVertices()
Returns a vector of the 2 bottom vertices. |
Point2D |
centre()
Returns the centre. |
Point2D |
centreAxisPointBottom()
Returns the point on the bottom edge that the locally vertical centre-line passes through; ie the mid-point of bottomEdge(). |
Point2D |
centreAxisPointLeft()
Returns the point on the left-hand edge that the locally horizontal centre-line passes through; ie the mid-point of leftEdge(). |
Point2D |
centreAxisPointRight()
Returns the point on the right-hand edge that the locally horizontal centre-line passes through; ie the mid-point of rightEdge(). |
Point2D |
centreAxisPointTop()
Returns the point on the top edge that the locally vertical centre-line passes through; ie the mid-point of topEdge(). |
Vector2D |
centreLineAxis(boolean normalised)
Returns the vector from the rectangle centre to the centreAxisPointRight() point. |
double |
height()
Returns the height. |
boolean |
isAxisAligned(double tolerance)
Tests whethr or not this rectangle is axis-aligned; ie both bottom and top edges are horizontal and both left and right edges are vertical. |
boolean |
isEdgesPerpendicular(double tolerance)
Method for testing that all 4 edges are perpendicular, thus defining a valid rectangle. |
boolean |
isSquare(double tolerance)
Tests whether or not this rectangle is a square. |
boolean |
isValid(double tolerance)
Tests whether or not this rectangle is valid. |
StraightLine2D |
leftEdge()
Returns the left edge. |
java.util.Vector<Point2D> |
leftVertices()
The 2 left-hand-side vertices. |
StraightLine2D |
rightEdge()
Returns the right ege. |
java.util.Vector<Point2D> |
rightVertices()
The 2 right-hand-side vertices. |
StraightLine2D |
topEdge()
Returns the top edge. |
Point2D |
topLeftVertex()
The top left vertex. |
Point2D |
topRightVertex()
The top right vertex. |
java.util.Vector<Point2D> |
topVertices()
Returns a vector of the 2 top vertices. |
double |
width()
Returns the width. |
| Methods inherited from class com.hedgehog.geo.twod.shapes.ConvexQuadrilateral2D |
|---|
bimediane0e2, bimediane1e3, diagonalLengths, diagonalv0v1, diagonalv1v3, isParallelogram, isTrapezium, perpendicularDiagonals, polygonType, semiPerimeter |
| Methods inherited from class com.hedgehog.geo.twod.shapes.Shape2D |
|---|
areaDifference, is2D, is3D, isCurve, isGrid, isMesh, isPoint, isPointSet, isShape, isSurface, translate |
| Methods inherited from class com.hedgehog.geo.GeometricObject |
|---|
objectDimension |
| Methods inherited from class com.hedgehog.HObject |
|---|
clone, compare, compareTo, copy, equals, getID, getName, hashCode, hasID, hasName, setID, setName |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface com.hedgehog.model.ModelObject |
|---|
childModelObjects, databaseInsertStatement, databaseUpdateStatement, fromDatabase, fromXMLNode, toX3DNode, toXMLNode |
| Constructor Detail |
|---|
public Rectangle2D()
public Rectangle2D(java.util.Vector<Point2D> vertices)
throws java.lang.IllegalArgumentException
vertices - Vector polygon vertices.
java.lang.IllegalArgumentException - Thrown if argument vertices does not have 4 elements.
public Rectangle2D(Point2D p0,
Point2D p1,
Point2D p2,
Point2D p3)
p0 - Point 0.p1 - Point 1.p2 - Point 2.p3 - Point 3.public Rectangle2D(Rectangle2D object)
object - Object to copy.| Method Detail |
|---|
public Point2D bottomLeftVertex()
public Point2D bottomRightVertex()
public Point2D topLeftVertex()
public Point2D topRightVertex()
public java.util.Vector<Point2D> bottomVertices()
public java.util.Vector<Point2D> topVertices()
public java.util.Vector<Point2D> leftVertices()
public java.util.Vector<Point2D> rightVertices()
public StraightLine2D bottomEdge()
public StraightLine2D rightEdge()
public StraightLine2D topEdge()
public StraightLine2D leftEdge()
public Point2D centreAxisPointRight()
public Point2D centreAxisPointLeft()
public Point2D centreAxisPointBottom()
public Point2D centreAxisPointTop()
public Vector2D centreLineAxis(boolean normalised)
normalised - Indicates whether or not the returned vector is to be normalised.
public double angleOfRotation(boolean degrees)
degrees - Specifies whetheror not the returned angle is in degrees or radians.
public boolean isSquare(double tolerance)
tolerance - Required tolerance.
public double width()
public double height()
public Point2D centre()
public boolean isValid(double tolerance)
isValid in class Polygon2Dtolerance - Required tolerance.
public boolean isEdgesPerpendicular(double tolerance)
tolerance - Required tolerance.
public boolean isAxisAligned(double tolerance)
tolerance - Required tolerance.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||