math.geom2d.spline
Class GeneralPath2D
- java.lang.Object
-
- math.geom2d.spline.GeneralPath2D
-
- All Implemented Interfaces:
- java.lang.Cloneable, Curve2D, GeometricObject2D, Shape2D
public class GeneralPath2D extends java.lang.Object implements Curve2D
-
-
Constructor Summary
Constructors Constructor and Description GeneralPath2D()Initialize an empty path.GeneralPath2D(GeneralPath2D path)Copy constructor.
-
Method Summary
All 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.java.awt.geom.Path2DasAwtShape()Transform to a java Path2D object.Box2DboundingBox()Returns the bounding box of the shape.CurveSet2D<? extends Curve2D>clip(Box2D box)When a curve is clipped, the result is a set of curves.GeneralPath2Dclone()voidclosePath()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 ContinuousCurve2D>continuousCurves()Returns the collection of continuous curves which constitute this curve.voidcubicTo(Point2D p1, Point2D p2, Point2D p3)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 curve on the given Graphics2D object.booleanequals(java.lang.Object obj)Point2DfirstPoint()Returns the first point of the curve, or null if this curve is empty.doublegetT0()doublegetT1()java.util.Collection<Point2D>intersections(LinearShape2D line)Returns the intersection points of the curve with the specified line.booleanisBounded()Returns true, as a curve composed of Bezier pieces is always bounded.booleanisEmpty()Returns true if the shape does not contain any point.booleanisSingular(double pos)Checks if a point is singular.Point2DlastPoint()Returns the last point of the curve, or null if this curve is empty.voidlineTo(Point2D p)voidmoveTo(Point2D p)Point2Dpoint(double t)Returns the point located at the given position on the curve.doubleposition(Point2D point)Computes the position of the point on the curve.doubleproject(Point2D point)Returns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point.voidquadTo(Point2D p1, Point2D p2)Curve2Dreverse()Returns the curve with same trace on the plane with parameterization in reverse order.java.util.Collection<Point2D>singularPoints()Returns a set of singular points, i.Curve2DsubCurve(double t0, double t1)Returns a portion of the original curve, delimited by two positions on the curve.doublet0()The first parameterization value is equal to 0.doublet1()The last parameterization value is given by the number of elementary operations (moveTo, closePath, lineTo...) minus one (for the initial move).Curve2Dtransform(AffineTransform2D trans)Transforms the curve by an affine transform.java.util.Collection<Point2D>vertices()Returns the set of vertices for this curve.
-
-
-
Constructor Detail
-
GeneralPath2D
public GeneralPath2D()
Initialize an empty path.
-
GeneralPath2D
public GeneralPath2D(GeneralPath2D path)
Copy constructor.
-
-
Method Detail
-
moveTo
public void moveTo(Point2D p)
-
lineTo
public void lineTo(Point2D p)
-
closePath
public void closePath()
-
t0
public double t0()
The first parameterization value is equal to 0.
-
t1
public double t1()
The last parameterization value is given by the number of elementary operations (moveTo, closePath, lineTo...) minus one (for the initial move).
-
point
public Point2D point(double t)
Description copied from interface:Curve2DReturns the point located at the given position on the curve. If the parameter lies outside the definition range, the parameter corresponding to the closest bound is used instead. This method can be used to draw an approximated outline of a curve, by selecting multiple values for t and drawing lines between them.
-
firstPoint
public Point2D firstPoint()
Returns the first point of the curve, or null if this curve is empty.- Specified by:
firstPointin interfaceCurve2D- Returns:
- the first point of the curve
- See Also:
Curve2D.t0(),Curve2D.point(double)
-
lastPoint
public Point2D lastPoint()
Returns the last point of the curve, or null if this curve is empty.- Specified by:
lastPointin interfaceCurve2D- Returns:
- the last point of the curve.
- See Also:
Curve2D.t1(),Curve2D.point(double)
-
singularPoints
public java.util.Collection<Point2D> singularPoints()
Description copied from interface:Curve2DReturns a set of singular points, i. e. which do not locally admit derivative.- Specified by:
singularPointsin interfaceCurve2D- Returns:
- a collection of Point2D.
- See Also:
Curve2D.vertices()
-
vertices
public java.util.Collection<Point2D> vertices()
Description copied from interface:Curve2DReturns the set of vertices for this curve. Vertices can be either singular points, or extremities.- Specified by:
verticesin interfaceCurve2D- Returns:
- a collection of Point2D.
- See Also:
Curve2D.singularPoints()
-
isSingular
public boolean isSingular(double pos)
Description copied from interface:Curve2DChecks if a point is singular.- Specified by:
isSingularin interfaceCurve2D- Parameters:
pos- the position of the point on the curve- Returns:
- true if the point at this location is singular
-
position
public double position(Point2D point)
Description copied from interface:Curve2DComputes the position of the point on the curve. If the point does not belong to the curve, return Double.NaN. It is complementary to thepoint(double)method.- Specified by:
positionin interfaceCurve2D- Parameters:
point- a point belonging to the curve- Returns:
- the position of the point on the curve
- See Also:
Curve2D.point(double)
-
project
public double project(Point2D point)
Description copied from interface:Curve2DReturns the position of the closest orthogonal projection of the point on the curve, or of the closest singular point. This function should always returns a valid value.
-
intersections
public java.util.Collection<Point2D> intersections(LinearShape2D line)
Description copied from interface:Curve2DReturns the intersection points of the curve with the specified line. The length of the result array is the number of intersection points.- Specified by:
intersectionsin interfaceCurve2D
-
reverse
public Curve2D reverse()
Description copied from interface:Curve2DReturns the curve with same trace on the plane with parameterization in reverse order.
-
continuousCurves
public java.util.Collection<? extends ContinuousCurve2D> continuousCurves()
Description copied from interface:Curve2DReturns the collection of continuous curves which constitute this curve.- Specified by:
continuousCurvesin interfaceCurve2D- Returns:
- a collection of continuous curves.
-
subCurve
public Curve2D subCurve(double t0, double t1)
Description copied from interface:Curve2DReturns a portion of the original curve, delimited by two positions on the curve.
-
asAwtShape
public java.awt.geom.Path2D asAwtShape()
Transform to a java Path2D object.- Specified by:
asAwtShapein interfaceCurve2D- Returns:
- the shape corresponding to this curve
-
contains
public boolean contains(Point2D p)
Description copied from interface:Shape2DChecks if the shape contains the given point.
-
contains
public boolean contains(double x, double y)Description copied from interface:Shape2DChecks if the shape contains the planar point defined by (x,y).
-
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, as a curve composed of Bezier pieces is always bounded.
-
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.
-
boundingBox
public Box2D boundingBox()
Description copied from interface:Shape2DReturns the bounding box of the shape.- Specified by:
boundingBoxin interfaceShape2D- Returns:
- the bounding box of the shape.
-
clip
public CurveSet2D<? extends Curve2D> clip(Box2D box)
Description copied from interface:Curve2DWhen a curve is clipped, the result is a set of curves.
-
transform
public Curve2D transform(AffineTransform2D trans)
Description copied from interface:Curve2DTransforms the curve by an affine transform. The result is an instance of Curve2D.
-
draw
public void draw(java.awt.Graphics2D g2)
Description copied from interface:Curve2DDraws the curve on the given Graphics2D object.
-
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
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
clone
public GeneralPath2D clone()
-
-
DMelt 3.0 © DataMelt by jWork.ORG