- Direct Known Subclasses:
Rectangle3D.Double
,Rectangle3D.Float
Rectangle2D
in order to reduce the learning curve.
A point is considered to lie inside the rectangular cuboid, and thus to be contained by it, if all of the following are true:
- the point is completely inside the cuboid.
- the point lies on the boundary and the space adjacent to
- the point is on the boundary of the cuboid and there exists a point with a larger X value that is inside the cuboid
- the point is on the boundary of the cuboid and there exists a point with a larger Y value that is inside the cuboid
- the point is on the boundary of the cuboid and there exists a point with a larger Z value that is inside the cuboid
Shape
interface and specifically the class
Rectangle2D
.
Note: this documentation was in part based nearly literally on
the documentation for the class Rectangle2D
.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Subclass ofRectangle3D
that stores its values as double-precision numbers.static class
Subclass ofRectangle3D
that stores its values as single-precision numbers. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(double newx, double newy, double newz) Adds a point, specified by its coordinates, to this Rectangle3D.void
Adds a point to this Rectangle3D.void
add
(Rectangle3D r) Adds a Rectangle3D object to this Rectangle3D.clone()
boolean
contains
(double x, double y, double z) Tests if the specified coordinates are inside this Rectangle3D.boolean
contains
(double x, double y, double z, double w, double h, double d) Tests if all the points inside the specified rectangular cuboid, specified by coordinates and dimensions, are inside this cuboid.boolean
Test if a point is contained by this rectangular cuboid.boolean
Tests if all the points inside the specified rectangular cuboid are inside this cuboid.Returns a new Rectangle3D object representing the intersection of this Rectangle3D with the specified Rectangle3D.Returns a new Rectangle3D object representing the union of this Rectangle3D with the specified Rectangle3D.boolean
Get the boundary for this Shape3D.Get a bounding rectangular cuboid for a 3D shape.double
Get the X coordinate for the center of this rectangular cuboid.double
Get the Y coordinate for the center of this rectangular cuboid.double
Get the Z coordinate for the center of this rectangular cuboid.getComponent
(int i) Get a component of this shape.abstract double
getDepth()
Get the depth of this rectangular cuboid.abstract double
Get the height of this rectangular cuboid.double
getMaxX()
/** Get the maximum X coordinate for this rectangular cuboiddouble
getMaxY()
Get the maximum Y coordinate for this rectangular cuboiddouble
getMaxZ()
Get the maximum Z coordinate for this rectangular cuboidabstract double
getMinX()
Get the minimum X coordinate for this rectangular cuboidabstract double
getMinY()
Get the minimum Y coordinate for this rectangular cuboidabstract double
getMinZ()
Get the minimum Z coordinate for this rectangular cuboidgetSurfaceIterator
(Transform3D tform) Get a surface iterator for this object.getSurfaceIterator
(Transform3D tform, int level) Get a surface iterator for this Shape3D, subdividing the surface.abstract double
getWidth()
Get the width of this rectangular cuboid.int
hashCode()
static void
intersect
(Rectangle3D src1, Rectangle3D src2, Rectangle3D dest) Intersects two source Rectangle3D objects and puts the result into the specified destination Rectangle3D object.boolean
intersects
(double x, double y, double z, double w, double h, double d) Determine if this rectangular cuboid intersects a rectangular cuboid that is specified by its corner and the length of its edges.boolean
Determine if this rectangular cuboid intersects another rectangular cuboid.boolean
Determine if this Shape3D is a closed two-dimensional manifold.boolean
isEmpty()
Tests if a Rectangle3D object is empty.boolean
Determine if a surface is oriented.int
Get the number of components for this shape.void
Set a rectangle's color.abstract void
setRect
(double x, double y, double z, double w, double h, double d) Set the configuration of this object given explicit coordinates and dimensionsvoid
Set the configuration of this object to that of a specified Rectangle3D.void
setRectFromCenter
(double centerX, double centerY, double centerZ, double cornerX, double cornerY, double cornerZ) Set the configuration of this object based on the coordinates of the center of this cuboid and the coordinates of a corner.void
setRectFromCenter
(Point3D center, Point3D corner) Set the configuration of this object based on points at the center of this cuboid and a corner of this cuboid.void
setRectFromDiagonal
(double x1, double y1, double z1, double x2, double y2, double z2) Set the configuration of this object based on the coordinates of vertices that lie along a diagonal.void
setRectFromDiagonal
(Point3D p1, Point3D p2) Set the configuration of this object based on vertices that lie along a diagonal.static void
union
(Rectangle3D src1, Rectangle3D src2, Rectangle3D dest) Sets a destination Rectangle3D to the union of two source Rectangle3D objects.Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.bzdev.geom.Shape3D
getBoundary
-
Field Details
-
STACKTRACE
Psuedo tag. Using this object as a tag will cause the tag to be a stack trace.
-
-
Constructor Details
-
Rectangle3D
public Rectangle3D()
-
-
Method Details
-
isOriented
public boolean isOriented()Description copied from interface:Shape3D
Determine if a surface is oriented.- Specified by:
isOriented
in interfaceShape3D
- Returns:
- true if the surface has an orientation; false if it does not
-
getBoundary
Description copied from interface:Shape3D
Get the boundary for this Shape3D. For a closed surface, the boundary will be an empty path.Typically, a boundary will consist of a series of distinct closed subpaths. Subpaths are separated by segments whose type is {link PathIterator3D#SEG_MOVETO}. For a closed manifold, the boundary will be an empty path.
- Specified by:
getBoundary
in interfaceShape3D
- Returns:
- the boundary of this surface; null if a boundary cannot be computed
- See Also:
-
isClosedManifold
public boolean isClosedManifold()Description copied from interface:Shape3D
Determine if this Shape3D is a closed two-dimensional manifold.- Specified by:
isClosedManifold
in interfaceShape3D
- Returns:
- true if the surface is a closed two-dimensional manifold; false otherwise
-
numberOfComponents
public int numberOfComponents()Description copied from interface:Shape3D
Get the number of components for this shape. Components are connected shapes - surfaces for which every point can connect to any other point.- Specified by:
numberOfComponents
in interfaceShape3D
- Returns:
- the number of components for this shape
-
getComponent
Description copied from interface:Shape3D
Get a component of this shape. Components are connected shapes - surfaces for which every point can connect to any other point. The components are referenced by an index, specified as an integer in the range [0,n), where n is the number of manifold components. If n is zero, no index is valid.- Specified by:
getComponent
in interfaceShape3D
- Parameters:
i
- the component's index- Returns:
- a model containing the specified component
- Throws:
IllegalArgumentException
- the argument is out of range- See Also:
-
setColor
Set a rectangle's color.- Parameters:
c
- the color for this rectangle; null if none is specified
-
add
public void add(double newx, double newy, double newz) Adds a point, specified by its coordinates, to this Rectangle3D. The resulting Rectangle3D is the smallest Rectangle3D that contains both the original Rectangle3D and the specified point (newx, newy, newz) specified by the arguments.After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.
- Parameters:
newx
- the X coordinate of the new pointnewy
- the Y coordinate of the new pointnewz
- the Z coordinate of the new point
-
add
Adds a point to this Rectangle3D. The resulting Rectangle3D is the smallest Rectangle3D that contains both the original Rectangle3D and the specified point (newx, newy, newz) specified by the arguments.After adding a point, a call to contains with the added point as an argument does not necessarily return true. The contains method does not return true for points on the right or bottom edges of a rectangle. Therefore, if the added point falls on the left or bottom edge of the enlarged rectangle, contains returns false for that point.
- Parameters:
p
- the new point
-
add
Adds a Rectangle3D object to this Rectangle3D. The resulting Rectangle3D is the union of the two Rectangle2D objects.- Parameters:
r
- the rectangle to add
-
createIntersection
Returns a new Rectangle3D object representing the intersection of this Rectangle3D with the specified Rectangle3D.- Parameters:
r
- the Rectangle2D to be intersected with this Rectangle3D- Returns:
- the largest Rectangle3D contained in both the specified Rectangle3D and in this Rectangle3D.
-
createUnion
Returns a new Rectangle3D object representing the union of this Rectangle3D with the specified Rectangle3D.- Parameters:
r
- the Rectangle3D to be intersected with this Rectangle3D- Returns:
- the smallest Rectangle3D containing both the specified Rectangle3D and this Rectangle2D
-
contains
public boolean contains(double x, double y, double z) Tests if the specified coordinates are inside this Rectangle3D. A point is contained by this rectangle if it is inside it.- Parameters:
x
- the X coordinatey
- the Y coordinatez
- the Z coordinate- Returns:
- true if the point denoted by the specified coordinates are inside this cuboid; false otherwise
-
contains
public boolean contains(double x, double y, double z, double w, double h, double d) Tests if all the points inside the specified rectangular cuboid, specified by coordinates and dimensions, are inside this cuboid. A point is contained by this rectangle if it is inside it.- Parameters:
x
- the X coordinate of the specified cuboid's minimum X valuey
- the Y coordinate of the specified cuboid's minimum Y valuez
- the Z coordinate of the specified cuboid's minimum Z valuew
- the width of the specified cuboid (its length in the X direction)h
- the height of the specified cuboid (its length in the Y direction)d
- the depth of the specified cuboid (its length in the Z direction)- Returns:
- true if the specified rectangular cuboid are inside this cuboid; false otherwise
-
contains
Test if a point is contained by this rectangular cuboid. A point is contained by this rectangle if it is inside it.- Parameters:
p
- a point- Returns:
- true if the specified point is within this cuboid; false otherwise
-
contains
Tests if all the points inside the specified rectangular cuboid are inside this cuboid. A point is contained by this rectangle if it is inside it.- Parameters:
r
- the specified rectangular cuboid- Returns:
- true if the points inside r are within this cuboid; false otherwise
-
getHeight
public abstract double getHeight()Get the height of this rectangular cuboid. The height is defined as the length in the Y direction.- Returns:
- the height
-
getWidth
public abstract double getWidth()Get the width of this rectangular cuboid. The width is defined as the length in the X direction.- Returns:
- the width
-
getDepth
public abstract double getDepth()Get the depth of this rectangular cuboid. The depth is defined as the length in the Z direction.- Returns:
- the depth
-
getMinX
public abstract double getMinX()Get the minimum X coordinate for this rectangular cuboid- Returns:
- the minimum X coordinate
-
getMinY
public abstract double getMinY()Get the minimum Y coordinate for this rectangular cuboid- Returns:
- the minimum Y coordinate
-
getMinZ
public abstract double getMinZ()Get the minimum Z coordinate for this rectangular cuboid- Returns:
- the minimum Z coordinate
-
getMaxX
public double getMaxX()/** Get the maximum X coordinate for this rectangular cuboid- Returns:
- the maximum X coordinate
-
getMaxY
public double getMaxY()Get the maximum Y coordinate for this rectangular cuboid- Returns:
- the maximum Y coordinate
-
getMaxZ
public double getMaxZ()Get the maximum Z coordinate for this rectangular cuboid- Returns:
- the maximum Z coordinate
-
getCenterX
public double getCenterX()Get the X coordinate for the center of this rectangular cuboid.- Returns:
- the X coordinate for the center of this rectangular cuboid
-
getCenterY
public double getCenterY()Get the Y coordinate for the center of this rectangular cuboid.- Returns:
- the Y coordinate for the center of this rectangular cuboid
-
getCenterZ
public double getCenterZ()Get the Z coordinate for the center of this rectangular cuboid.- Returns:
- the Z coordinate for the center of this rectangular cuboid
-
intersects
Determine if this rectangular cuboid intersects another rectangular cuboid.- Parameters:
r
- the other rectangular cuboid- Returns:
- true if this cuboid and the other cuboid intersect; false otherwise
-
intersects
public boolean intersects(double x, double y, double z, double w, double h, double d) Determine if this rectangular cuboid intersects a rectangular cuboid that is specified by its corner and the length of its edges.- Parameters:
x
- the X coordinate of the specified cuboid's minimum X valuey
- the Y coordinate of the specified cuboid's minimum Y valuez
- the Z coordinate of the specified cuboid's minimum Z valuew
- the width of the specified cuboid (its length in the X direction)h
- the height of the specified cuboid (its length in the Y direction)d
- the depth of the specified cuboid (its length in the Z direction)- Returns:
- true if this cuboid and the specified cuboid intersect; false otherwise
-
intersect
Intersects two source Rectangle3D objects and puts the result into the specified destination Rectangle3D object. The destination object can be one of the source objects, if desired, in which case a source object will be overridden.- Parameters:
src1
- the first source Rectangle3D objectsrc2
- the second source Rectangle3D objectdest
- the destination Rectangle3D object
-
isEmpty
public boolean isEmpty()Tests if a Rectangle3D object is empty. A Rectangle3D is empty if its width, height, and depth are all zero.- Returns:
- true if this object is empty; false otherwise
-
clone
-
getBounds
Description copied from interface:Shape3D
Get a bounding rectangular cuboid for a 3D shape. The edges will be aligned with the X, Y and Z axes. The cuboid created may not be the smallest one possible (for example, shapes defined by Bézier surfaces may just use the control points to determine the cuboid as the convex hull for the control points includes all of the surface for parameters in the normal range [0,1]). -
getSurfaceIterator
Get a surface iterator for this object.The transform should either be an affine transform or well-approximated by an affine transform over the surface of this rectangle.
- Specified by:
getSurfaceIterator
in interfaceShape3D
- Parameters:
tform
- a transform to apply to the cuboid; null if the identity transform will be used- Returns:
- a surface iterator
-
getSurfaceIterator
Description copied from interface:Shape3D
Get a surface iterator for this Shape3D, subdividing the surface. The surface iterator will represent the shape as a sequence of Bézier patches and Bézier triangles, with the order of the sequence arbitrary.Unless the transform is an affine transform, the transformation is not exact. In this case, the patches and triangles that constitute the surface after each is subdivided should be small enough that the transform can be approximated by an affine transform over the region containing the control points.
- Specified by:
getSurfaceIterator
in interfaceShape3D
- Parameters:
tform
- a transform to apply to each control point; null for the identity transformlevel
- the number of levels of partitioning (each additional level splits the previous level into quarters)- Returns:
- a surface iterator
-
setRect
public abstract void setRect(double x, double y, double z, double w, double h, double d) Set the configuration of this object given explicit coordinates and dimensions- Parameters:
x
- the X coordinate of the vertex whose coordinates have a minimal value.y
- the Y coordinate of the vertex whose coordinates have a minimal value.z
- the Z coordinate of the vertex whose coordinates have a minimal value.w
- the width of the object (the length in the X direction)h
- the height of the object (the length in the Y direction)d
- the depth of the object (the length in the Z direction)
-
setRect
Set the configuration of this object to that of a specified Rectangle3D.- Parameters:
r
- the object that will be copied.
-
setRectFromDiagonal
public void setRectFromDiagonal(double x1, double y1, double z1, double x2, double y2, double z2) Set the configuration of this object based on the coordinates of vertices that lie along a diagonal.- Parameters:
x1
- the X coordinate of the first vertexy1
- the Y coordinate of the first vertexz1
- the Z coordinate of the first vertexx2
- the X coordinate of the second vertexy2
- the Y coordinate of the second vertexz2
- the Z coordinate of the second vertex
-
setRectFromDiagonal
Set the configuration of this object based on vertices that lie along a diagonal.- Parameters:
p1
- a point at the location of the first vertexp2
- a point at the location of the second vertex
-
setRectFromCenter
public void setRectFromCenter(double centerX, double centerY, double centerZ, double cornerX, double cornerY, double cornerZ) Set the configuration of this object based on the coordinates of the center of this cuboid and the coordinates of a corner.- Parameters:
centerX
- the X coordinate of the center of the desired cuboidcenterY
- the Y coordinate of the center of the desired cuboidcenterZ
- the Y coordinate of the center of the desired cuboidcornerX
- the X coordinate of a corner of the desired cuboidcornerY
- the Y coordinate of a corner of the desired cuboidcornerZ
- the Y coordinate of a corner of the desired cuboid
-
setRectFromCenter
Set the configuration of this object based on points at the center of this cuboid and a corner of this cuboid.- Parameters:
center
- a point positioned at the center of the desired cuboidcorner
- a point positioned at a corner of the desired cuboid
-
equals
-
hashCode
public int hashCode() -
union
Sets a destination Rectangle3D to the union of two source Rectangle3D objects. The destination object can be one of the source objects, if desired, in which case a source object will be overridden.- Parameters:
src1
- the first source Rectangle3D objectsrc2
- the second source Rectangle3D objectdest
- the destination Rectangle3D object
-