Package org.djutils.draw.curve
Class Straight2d
java.lang.Object
org.djutils.draw.curve.Straight2d
- All Implemented Interfaces:
Curve<DirectedPoint2d,
,Double, Point2d, Flattener2d, PolyLine2d> Curve2d
,Flattener.FlattableCurve<Point2d,
,Double> OffsetCurve2d
Continuous curve implementation of a straight in 2d.
Copyright (c) 2023-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See OpenTrafficSim License.
- Author:
- Alexander Verbraeck, Peter Knoppers, Wouter Schakel
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondouble
End curvature of this Straight.double
Return the length of this Curve.getPoint
(double fraction) Returns the point at the given fraction of this Curve.getPoint
(double fraction, ContinuousPiecewiseLinearFunction of) Returns the point at the given fraction.double
Start curvature of this Straight.offset
(ContinuousPiecewiseLinearFunction offsets) Offset a PolyLine2d based on variable offset.toPolyLine
(Flattener2d flattener) Flatten a Curve into a PolyLine.toPolyLine
(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets) Flatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.djutils.draw.curve.Curve2d
getDirection, getEndDirection, getEndPoint, getStartDirection, getStartPoint
Methods inherited from interface org.djutils.draw.curve.OffsetCurve2d
getDirection, getT
-
Constructor Details
-
Straight2d
Constructor.- Parameters:
startPoint
- start point.length
- length.- Throws:
NullPointerException
- whenstartPoint
isnull
IllegalArgumentException
- whenlength ≤ 0.0
-
-
Method Details
-
getStartCurvature
public double getStartCurvature()Start curvature of this Straight.- Returns:
- start curvature of this Straight
-
getEndCurvature
public double getEndCurvature()End curvature of this Straight.- Returns:
- end curvature of this Straight
-
getPoint
Description copied from interface:Curve
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.- Specified by:
getPoint
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Specified by:
getPoint
in interfaceFlattener.FlattableCurve<Point2d,
Double> - Parameters:
fraction
- the fraction- Returns:
- the point at the given
fraction
-
getPoint
Description copied from interface:OffsetCurve2d
Returns the point 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.- Specified by:
getPoint
in interfaceOffsetCurve2d
- Parameters:
fraction
- the fractionof
- provides fraction-dependent lateral offset to the point- Returns:
- the point at the given
fraction
-
toPolyLine
Description copied from interface:Curve
Flatten a Curve into a PolyLine. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLine
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Parameters:
flattener
- the flattener- Returns:
- approximation of this
Curve
as aPolyLine
-
offset
Offset a PolyLine2d based on variable offset. A straight uses no segments, other than for varying offset.- Parameters:
offsets
- offsets, should contain keys 0.0 and 1.0.- Returns:
- offset
PolyLine2d
-
toPolyLine
public PolyLine2d toPolyLine(OffsetFlattener2d flattener, ContinuousPiecewiseLinearFunction offsets) Description copied from interface:OffsetCurve2d
Flatten a Curve2d while offsetting with the provided continuous offset into a PolyLine2d. Implementations should use the flattener when relevant and possible.- Specified by:
toPolyLine
in interfaceOffsetCurve2d
- Parameters:
flattener
- OffsetFlatteneroffsets
- offset data- Returns:
- approximation of this
curve2d
with offset as aPolyLine2d
-
getLength
public double getLength()Description copied from interface:Curve
Return the length of this Curve.- Specified by:
getLength
in interfaceCurve<DirectedPoint2d,
Double, Point2d, Flattener2d, PolyLine2d> - Returns:
- length of this Curve
-
toString
-