Package org.djutils.draw.curve
Interface Curve<DP,DIR,P extends Point<P>,F extends Flattener<F,?,PL,P,DIR>,PL extends PolyLine<?,P,?,?,?>>
- Type Parameters:
DP
- theDirectedPoint
typeDIR
- the direction type. In 2d this is ajava.lang.Double
; in 3d this is aDirection3d
objectP
- thePoint
typeF
- theFlattener
typePL
- thePolyLine
type
- All Known Subinterfaces:
Curve2d
,Curve3d
,OffsetCurve2d
- All Known Implementing Classes:
Arc2d
,Bezier2d
,Bezier3d
,BezierCubic2d
,BezierCubic3d
,Clothoid2d
,Straight2d
public interface Curve<DP,DIR,P extends Point<P>,F extends Flattener<F,?,PL,P,DIR>,PL extends PolyLine<?,P,?,?,?>>
A Curve defines a line in an exact, continuous manner, from which numerically approximated polylines can be derived. The
continuous definition is useful to accurately connect different lines, e.g. based on the direction of the point where they
meet. Moreover, this direction may be accurately be determined by either of the lines. For example, an arc can be defined up
to a certain angle. Whatever the angle of the last line segment in a polyline for the arc may be, the continuous line
contains the final direction exactly. The continuous definition is also useful to define accurate offset lines, which depend
on accurate directions especially at the line end points.
Copyright (c) 2024-2025 Delft University of Technology, Jaffalaan 5, 2628 BX Delft, the Netherlands. All rights reserved. See for project information https://djutils.org. The DJUTILS project is distributed under a three-clause BSD-style license, which can be found at https://djutils.org/docs/license.html.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Method Summary
Modifier and TypeMethodDescriptiongetDirection
(double fraction) Returns the direction at the given fraction.End direction of this Curve.End point of this Curve.getKnots()
If this Curve has knots, this method must return the fractions where those knots occur.double
Return the length of this Curve.getPoint
(double fraction) Returns the point at the given fraction of this Curve.Start direction of this Curve.Start point of this Curve.toPolyLine
(F flattener) Flatten a Curve into a PolyLine.
-
Method Details
-
getStartPoint
DP getStartPoint()Start point of this Curve.- Returns:
- start point of this Curve
-
getEndPoint
DP getEndPoint()End point of this Curve.- Returns:
- end point of this Curve
-
getLength
double getLength()Return the length of this Curve.- Returns:
- length of this Curve
-
getStartDirection
DIR getStartDirection()Start direction of this Curve.- Returns:
- start direction of this Curve
-
getEndDirection
DIR getEndDirection()End direction of this Curve.- Returns:
- end direction of this Curve
-
toPolyLine
Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.- Parameters:
flattener
- the flattener- Returns:
- approximation of this
Curve
as aPolyLine
-
getPoint
Returns the point at the given fraction of this Curve. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length.- Parameters:
fraction
- the fraction- Returns:
- the point at the given
fraction
-
getKnots
If this Curve has knots, this method must return the fractions where those knots occur. Thedefault
implementation works for Curves that have no knots.- Returns:
- Set<Double> the fractions where knots in the offset function occur, may be empty or
null
-
getDirection
Returns the direction at the given fraction. The fraction may represent any parameter, such as t in a Bézier curve, s in a Clothoid, or simply the fraction of length. The default implementation performs a numerical approach by looking at the direction between the points at fraction, and a point 1e-6 away.- Parameters:
fraction
- the fraction- Returns:
- the direction at the given
fraction
-