math.geom2d.curve
Class Curves2D
- java.lang.Object
-
- math.geom2d.curve.Curves2D
-
public abstract class Curves2D extends java.lang.ObjectCollects some useful methods for clipping curves.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class and Description static classCurves2D.JunctionType
-
Constructor Summary
Constructors Constructor and Description Curves2D()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method and Description static doublechoosePosition(double t0, double t1)Choose an arbitrary position between positions t0 and t1, which can be infinite.static CurveSet2D<ContinuousCurve2D>clipContinuousCurve(ContinuousCurve2D curve, Box2D box)Clips a continuous curve and returns a set of continuous curves.static CurveSet2D<? extends Curve2D>clipCurve(Curve2D curve, Box2D box)Clip a curve, and return a CurveSet2D.static CurveSet2D<? extends Curve2D>clipCurveSet(CurveSet2D<?> curveSet, Box2D box)clip a CurveSet2D.static CurveSet2D<SmoothCurve2D>clipSmoothCurve(SmoothCurve2D curve, Box2D box)Clip a continuous smooth curve.static CurveSet2D<SmoothCurve2D>clipSmoothCurve(SmoothCurve2D curve, StraightLine2D line)Clip a continuous smooth curve by the half-plane defined by a line.static intfindNextCurveIndex(double[] positions, double pos)static doublefromUnitSegment(double t, double t0, double t1)Transforms the value t between 0 and 1 in a value comprised between t0 and t1.static ContinuousCurve2DgetFirstContinuousCurve(Curve2D curve)static SmoothCurve2DgetFirstSmoothCurve(Curve2D curve)static Curves2D.JunctionTypegetJunctionType(Curve2D prev, Curve2D next)Returns the junction type between the end of first curve and the beginning of second curve.static ContinuousCurve2DgetLastContinuousCurve(Curve2D curve)static SmoothCurve2DgetLastSmoothCurve(Curve2D curve)static booleanisLeftInfinite(Curve2D curve)static booleanisRightInfinite(Curve2D curve)static doubletoUnitSegment(double t, double t0, double t1)Mapping of the parameter t, relative to the local curve, into the interval [0 1], [0 1[, ]0 1], or ]0 1[, depending on the values of t0 and t1.
-
-
-
Method Detail
-
toUnitSegment
public static double toUnitSegment(double t, double t0, double t1)Mapping of the parameter t, relative to the local curve, into the interval [0 1], [0 1[, ]0 1], or ]0 1[, depending on the values of t0 and t1.- Parameters:
t- a value between t0 and t1t0- the lower bound of parameterization domaint1- the upper bound of parameterization domain- Returns:
- a value between 0 and 1
-
fromUnitSegment
public static double fromUnitSegment(double t, double t0, double t1)Transforms the value t between 0 and 1 in a value comprised between t0 and t1.- Parameters:
t- a value between 0 and 1t0- the lower bound of parameterization domaint1- the upper bound of parameterization domain- Returns:
- a value between t0 and t1
-
clipCurve
public static CurveSet2D<? extends Curve2D> clipCurve(Curve2D curve, Box2D box)
Clip a curve, and return a CurveSet2D. If the curve is totally outside the box, return a CurveSet2D with 0 curves inside. If the curve is totally inside the box, return a CurveSet2D with only one curve, which is the original curve.
-
clipCurveSet
public static CurveSet2D<? extends Curve2D> clipCurveSet(CurveSet2D<?> curveSet, Box2D box)
clip a CurveSet2D.
-
clipContinuousCurve
public static CurveSet2D<ContinuousCurve2D> clipContinuousCurve(ContinuousCurve2D curve, Box2D box)
Clips a continuous curve and returns a set of continuous curves.
Algorithm is the following one:
- Compute intersections between curve and box boundary
- Sort intersections according to their position on the curve
- Remove intersections which do not cross (they only touch) the box boundary
- Add portions of curves located between two intersections and inside of the box
Special processing is added when the first point of the curve lies on the boundary of the box, and when the curve is closed (when the first point of the curve is inside the box, the method return a portion of curve between the last intersection and the first intersection).
-
clipSmoothCurve
public static CurveSet2D<SmoothCurve2D> clipSmoothCurve(SmoothCurve2D curve, Box2D box)
Clip a continuous smooth curve. Currently just call the static method clipContinuousCurve, and cast clipped curves.
-
clipSmoothCurve
public static CurveSet2D<SmoothCurve2D> clipSmoothCurve(SmoothCurve2D curve, StraightLine2D line)
Clip a continuous smooth curve by the half-plane defined by a line. This method is mainly used to help debugging when implementing curves.
-
findNextCurveIndex
public static int findNextCurveIndex(double[] positions, double pos)
-
choosePosition
public static double choosePosition(double t0, double t1)Choose an arbitrary position between positions t0 and t1, which can be infinite.- Parameters:
t0- the first bound of a curve parameterizationt1- the second bound of a curve parameterization- Returns:
- a position located between t0 and t1
-
isLeftInfinite
public static boolean isLeftInfinite(Curve2D curve)
-
isRightInfinite
public static boolean isRightInfinite(Curve2D curve)
-
getFirstContinuousCurve
public static ContinuousCurve2D getFirstContinuousCurve(Curve2D curve)
-
getLastContinuousCurve
public static ContinuousCurve2D getLastContinuousCurve(Curve2D curve)
-
getFirstSmoothCurve
public static SmoothCurve2D getFirstSmoothCurve(Curve2D curve)
-
getLastSmoothCurve
public static SmoothCurve2D getLastSmoothCurve(Curve2D curve)
-
getJunctionType
public static Curves2D.JunctionType getJunctionType(Curve2D prev, Curve2D next)
Returns the junction type between the end of first curve and the beginning of second curve.
-
-
DMelt 3.0 © DataMelt by jWork.ORG