math.geom2d.domain
Class GenericDomain2D
- java.lang.Object
-
- math.geom2d.domain.GenericDomain2D
-
- All Implemented Interfaces:
- Domain2D, GeometricObject2D, Shape2D
- Direct Known Subclasses:
- GenericCirculinearDomain2D
public class GenericDomain2D extends java.lang.Object implements Domain2D
A domain defined from its boundary. The boundary curve must be correctly oriented, non self intersecting, and clearly separating interior and exterior.All contains and intersect tests are computed from the signed distance of the boundary curve.
-
-
Constructor Summary
Constructors Constructor and Description GenericDomain2D(Boundary2D boundary)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanalmostEquals(GeometricObject2D obj, double eps)Checks if the two objects are similar up to a given threshold value.Polygon2DasPolygon(int n)Returns an approximation of the domain as a polygon, or a MultiPolygon.Boundary2Dboundary()Returns the boundary of the set.Box2DboundingBox()If the domain is bounded, returns the bounding box of its boundary, otherwise returns an infinite bounding box.Domain2Dclip(Box2D box)Clip the shape with the given box, and returns a new shape.Domain2Dcomplement()Returns the domain which complements this domain in the plane.booleancontains(double x, double y)Checks if the shape contains the planar point defined by (x,y).booleancontains(Point2D p)Checks if the shape contains the given point.java.util.Collection<? extends Contour2D>contours()Returns the set of contours that enclose this domain.static GenericDomain2Dcreate(Boundary2D boundary)doubledistance(double x, double y)Returns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e.doubledistance(Point2D p)Returns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.voiddraw(java.awt.Graphics2D g2)Draws the boundary of the domain, using current Stroke and color.booleanequals(java.lang.Object obj)voidfill(java.awt.Graphics2D g2)Fills the interior of the domain, using the Graphics current Paint.booleanisBounded()Returns true if the domain is bounded.booleanisEmpty()Returns true if the shape does not contain any point.java.lang.StringtoString()GenericDomain2Dtransform(AffineTransform2D trans)Returns a new domain which is created from the transformed domain of this boundary.
-
-
-
Constructor Detail
-
GenericDomain2D
public GenericDomain2D(Boundary2D boundary)
-
-
Method Detail
-
create
public static GenericDomain2D create(Boundary2D boundary)
-
asPolygon
public Polygon2D asPolygon(int n)
Description copied from interface:Domain2DReturns an approximation of the domain as a polygon, or a MultiPolygon.
-
boundary
public Boundary2D boundary()
Description copied from interface:Domain2DReturns the boundary of the set. This boundary is either a continuous non intersecting curve (connected domain), or a set of non intersecting continuous curve (one continuous non-intersection for each connected part of the domain).The returned curve is oriented, with an interior and an exterior.
-
contours
public java.util.Collection<? extends Contour2D> contours()
Description copied from interface:Domain2DReturns the set of contours that enclose this domain. The result is a collection of shapes that implement the Contour2D interface.
-
complement
public Domain2D complement()
Description copied from interface:Domain2DReturns the domain which complements this domain in the plane.- Specified by:
complementin interfaceDomain2D- Returns:
- the complement of this domain.
-
distance
public double distance(Point2D p)
Description copied from interface:Shape2DReturns the distance of the shape to the given point, or the distance of point to the frontier of the shape in the case of a plain shape.
-
distance
public double distance(double x, double y)Description copied from interface:Shape2DReturns the distance of the shape to the given point, specified by x and y, or the distance of point to the frontier of the shape in the case of a plain (i.e. fillable) shape.
-
isBounded
public boolean isBounded()
Returns true if the domain is bounded. The domain is unbounded if either its boundary is unbounded, or a point located outside of the boundary bounding box is located inside of the domain.
-
isEmpty
public boolean isEmpty()
Description copied from interface:Shape2DReturns true if the shape does not contain any point. This is the case for example for PointSet2D without any point.
-
clip
public Domain2D clip(Box2D box)
Description copied from interface:Shape2DClip the shape with the given box, and returns a new shape. The box must be bounded.
-
boundingBox
public Box2D boundingBox()
If the domain is bounded, returns the bounding box of its boundary, otherwise returns an infinite bounding box.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
transform
public GenericDomain2D transform(AffineTransform2D trans)
Returns a new domain which is created from the transformed domain of this boundary.
-
contains
public boolean contains(double x, double y)Description copied from interface:Shape2DChecks if the shape contains the planar point defined by (x,y).
-
contains
public boolean contains(Point2D p)
Description copied from interface:Shape2DChecks if the shape contains the given point.
-
draw
public void draw(java.awt.Graphics2D g2)
Description copied from interface:Domain2DDraws the boundary of the domain, using current Stroke and color.
-
fill
public void fill(java.awt.Graphics2D g2)
Description copied from interface:Domain2DFills the interior of the domain, using the Graphics current Paint.
-
almostEquals
public boolean almostEquals(GeometricObject2D obj, double eps)
Description copied from interface:GeometricObject2DChecks if the two objects are similar up to a given threshold value. This method can be used to compare the results of geometric computations, that introduce errors due to numerical computations.- Specified by:
almostEqualsin interfaceGeometricObject2D- Parameters:
obj- the object to compareeps- a threshold value, for example the minimal coordinate difference- Returns:
- true if both object have the same value up to the threshold
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-
DMelt 3.0 © DataMelt by jWork.ORG