public class Rectangle extends Polygon implements Shape, Transformable
Rectangle
(either axis aligned or oriented).
A Rectangle
cannot have a width or height of zero.
Modifier and Type | Field and Description |
---|---|
protected double |
height
The
Rectangle 's height |
protected double |
width
The
Rectangle 's width |
center, id, radius, userData
Constructor and Description |
---|
Rectangle(double width,
double height)
Full constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
contains(Vector2 point,
Transform transform)
Returns true if the given point is inside this
Shape . |
Mass |
createMass(double density)
|
Vector2[] |
getAxes(Vector2[] foci,
Transform transform)
Returns an array of separating axes to test for this
Shape . |
double |
getHeight()
Returns the height.
|
double |
getRotation()
Returns the rotation about the local center in radians.
|
double |
getWidth()
Returns the width.
|
Interval |
project(Vector2 axis,
Transform transform)
|
java.lang.String |
toString() |
createAABB, getFarthestFeature, getFarthestPoint, getFoci, rotate, translate
getNormals, getRadius, getVertices
getCenter, getId, getRadius, getUserData, rotate, rotate, setUserData, translate
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
createAABB, getCenter, getId, getRadius, getRadius, getUserData, rotate, setUserData
rotate, rotate, translate, translate
protected double width
Rectangle
's widthprotected double height
Rectangle
's heightpublic Rectangle(double width, double height)
The center of the Rectangle
is (0, 0).
width
- the widthheight
- the heightjava.lang.IllegalArgumentException
- if width or height is less than or equal to zeropublic double getHeight()
public double getWidth()
public double getRotation()
public Vector2[] getAxes(Vector2[] foci, Transform transform)
Convex
Shape
.
Given some points, this method will return the separating axes for
this Shape
's voronoi regions also. The voronoi axes will not be included
if the foci array is null.
The points in the foci array are assumed to be in world space.
The returned axes are normalized.
public boolean contains(Vector2 point, Transform transform)
Shape
public Interval project(Vector2 axis, Transform transform)
Shape
public Mass createMass(double density)
Mass
object using the geometric properties of
this Rectangle
and the given density.
m = d * h * w I = m * (h2 + w2) / 12
createMass
in interface Shape
createMass
in class Polygon
density
- the density in kg/m2Mass
the Mass
of this Rectangle