![]() |
Trax3 3.1.0
trax track library
|
\ brief Cubic Hermite Spline. More...
#include <C:/Trend/Development/Trax3/Code/trax/Curve.h>

Public Types | |
| enum class | WrapTypes { none = 0 , nonperiodic , periodic , pinned } |
| Type of handling the ends: | |
| using | SegmentValueType = CubicData |
| using | Data = std::vector<SegmentValueType> |
| Data definig the curve. | |
| Public Types inherited from trax::Curve | |
| enum class | CurveType { none = 0 , Line , Arc , Helix , LineP , ArcP , HelixP , Clothoid , Cubic , Spline , Rotator , RotatorWithOffset , RotatorChain , PolygonalChain , SampledCurve , Parallel , EEPCurve , EEPResidual , EEPAlternative , Unknown , UserDefined } |
| Curve type identification values. More... | |
Public Member Functions | |
| virtual int | CountControlPoints () const noexcept=0 |
| virtual common::Interval< Length > | ResetControlPointAndTangent (int idx, const spat::VectorBundle< Length > &controlPointAndTangent)=0 |
| Resets a control point. | |
| virtual spat::VectorBundle< Length > | GetControlPointAndTangent (int idx) const =0 |
| virtual Length | GetParameter (int idx) const =0 |
| virtual int | UpperBound (Length s) const =0 |
| The index of the control point that is the first one to have greater parameter than s. | |
| virtual bool | HasGaps (Length epsilon=epsilon__length) const noexcept=0 |
| Check smoothness of the curve at the control points. | |
| virtual bool | HasKinks (Angle epsilon=epsilon__angle) const noexcept=0 |
| Check smoothness of the tangets of the curve at the control points. | |
| virtual common::Interval< Length > | Shorten (common::Interval< Length > toRange)=0 |
| Transforms the Spline to one with the given parameter range. | |
| virtual const Data & | GetData () const noexcept=0 |
| Retrieves the data to construct this curve type. A roundtrip is guaranteed to be invariant. | |
Creation | |
| virtual common::Interval< Length > | Create (const Curve &originalCurve, common::Interval< Length > range, Length maxDeviation=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 1000_m })=0 |
| Creates a spline curve from an existing curve. | |
| virtual common::Interval< Length > | Create (std::pair< std::shared_ptr< const Curve >, common::Interval< Length > > originalCurve, Length maxDeviation=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 1000_m })=0 |
| virtual common::Interval< Length > | Create (const std::vector< spat::VectorBundle< Length > > &controlPointsAndTangents)=0 |
| Creates a Cubic Hermite Spline, guaranteed to be C1 (points and tangents match). | |
| virtual common::Interval< Length > | Create (const std::vector< spat::Position< Length > > &controlPoints)=0 |
| Natural Cubic C2 - smooth Spline (points, tangent, normal and curvature of the segments match). | |
| virtual common::Interval< Length > | Create (const std::vector< spat::Position< Length > > &controlPoints, bool bClampedAtStart, const spat::Vector< Length > &startTangent, bool bClampedAtEnd, const spat::Vector< Length > &endTangent)=0 |
| Clamped Cubic C2 - smooth Spline (points, tangent, normal and curvature of the segments match). | |
| virtual common::Interval< Length > | CreateCatmullRom (const std::vector< spat::Position< Length > > &controlPoints, One tension=0.5f, WrapTypes wrap=WrapTypes::nonperiodic)=0 |
| C1 Spline with Pi'th tangent being: tension * (Pi+1 - Pi-1). | |
| virtual common::Interval< Length > | CreateCatmullRom (const std::vector< spat::VectorBundle< Length, One > > &controlPoints, One tension=0.5f, WrapTypes wrap=WrapTypes::nonperiodic)=0 |
| C1 Spline with Pi'th tangent being: tension * (Pi+1 - Pi-1).Length() * Ti. | |
| virtual common::Interval< Length > | CreateBezier (const std::vector< spat::Position< Length > > &controlPoints, WrapTypes wrap=WrapTypes::nonperiodic)=0 |
| C0 Spline from Cubic Bezier control points. | |
| virtual common::Interval< Length > | Create (const Data &data)=0 |
| Create the curve from data set for which it is guaranteed, that no calculational drift will happen, e.g. in write/read cycles. | |
| Public Member Functions inherited from trax::Curve | |
| virtual const char * | TypeName () const noexcept=0 |
| virtual CurveType | GetCurveType () const noexcept=0 |
| virtual bool | IsValid () const noexcept=0 |
| virtual AnglePerLength | Curvature (Length s) const =0 |
| virtual AnglePerLength | Torsion (Length s) const =0 |
| virtual bool | IsFlat () const noexcept=0 |
| virtual void | Transition (Length s, spat::Position< Length > &pos) const =0 |
| Copies the 3D Position at the specified location to pos. | |
| virtual void | Transition (Length s, spat::Vector< One > &tan) const =0 |
| Copies the 3D tangential vector at the specified location to tan. | |
| virtual void | Transition (Length s, spat::VectorBundle< Length, One > &bundle) const =0 |
| Copies the 3D Position and tangential vector at the specified location to bundle. | |
| virtual void | Transition (Length s, spat::VectorBundle2< Length, One > &bundle) const =0 |
| Copies the 3D Position and tangential and normal vectors at the specified location to bundle. | |
| virtual void | Transition (Length s, spat::Frame< Length, One > &frame) const =0 |
| Copies the 3D TBN-Frame at the specified location to frame. | |
| virtual std::vector< Length > | ZeroSet () const =0 |
| Returns a list of parameters at which the normal vector flips from one side to the other. | |
| virtual common::Interval< Length > | Range () const =0 |
| virtual spat::Vector< One > | LocalUp () const =0 |
| Gives the Curve's idiosyncratic up direction. Some curves maintain some idea about where they have their upside, either because of their form (e.g Helix) or because it is extra defined (e.g. for Line). Some curves maintain no such notion (e.g. many Cubics). | |
| virtual spat::Frame< Length, One > | GetCurveLocalTransformation () const =0 |
| virtual std::unique_ptr< Curve > | Clone () const =0 |
| make an exact copy of this curve. | |
| virtual bool | Mirror (const spat::VectorBundle< Length, One > &mirrorPlane)=0 |
| Make a Curve with mirrored geometry (but of course one thet returns right handed frames). | |
| virtual bool | Equals (const Curve &toCurve, common::Interval< Length > range, Length epsilon_length=epsilon__length, Angle epsilon_angle=epsilon__angle) const =0 |
| Comparison. | |
| Curve (Curve &&)=delete | |
| Curve & | operator= (const Curve &)=delete |
| Curve & | operator= (Curve &&)=delete |
Static Public Member Functions | |
| static dclspc std::unique_ptr< Spline > | Make () noexcept |
| Makes a Spline object. | |
Additional Inherited Members | |
| Protected Member Functions inherited from trax::Curve | |
| Curve (const Curve &)=default | |
| using trax::Spline::Data = std::vector<SegmentValueType> |
Type of the segments.
|
pure virtualnoexcept |
|
pure virtual |
Creates a spline curve from an existing curve.
| originalCurve | valid template curve. |
| range | range on the template curve |
| maxDeviation | the maximum positional deviation. |
| sampleDistanceLimits | The minimum and maximum distance between the sample points |
| std::invalid_argument | if originalCurve is not a valid curve, or the range of the curve does not intersect with range, or maxDeviation <= 0_m. |
| std::runtime_error | if the curve could not get created. |
|
pure virtual |
Create the curve from data set for which it is guaranteed, that no calculational drift will happen, e.g. in write/read cycles.
| std::invalid_argument | if the creation fails. |
|
pure virtual |
Natural Cubic C2 - smooth Spline (points, tangent, normal and curvature of the segments match).
These are used in railroading often (or better be). The curvatures at start and end are zero.
| controlPoints | A series of points to be connected by the spline. |
| std::invalid_argument | if there are less then two control points. |
|
pure virtual |
Clamped Cubic C2 - smooth Spline (points, tangent, normal and curvature of the segments match).
These are used in railroading often (or better be). The curvatures at start and end are given by the supplied tangent vectors. If both end are set to be not clamped, a Natural Cubic C2 spline will be generated.
| controlPoints | A series of points to be connected by the spline. |
| bClampedAtStart | If true the start tangent will be used. |
| bClampedAtEnd | If true the end tangent will be used. |
| startTangent | Tangent (and cubic overshoot) at start point. |
| endTangent | Tangent (and cubic overshoot) at end point. |
| std::invalid_argument | if there are less then two control points. |
|
pure virtual |
Creates a Cubic Hermite Spline, guaranteed to be C1 (points and tangents match).
There are methods to yield these controlPoint-tangents by different interpolation methods. See below.
| std::invalid_argument | if there are less then two control points. |
|
pure virtual |
| originalCurve | valid template curve. |
| maxDeviation | the maximum positional deviation. |
| sampleDistanceLimits | The minimum and maximum distance between the sample points |
| std::invalid_argument | if originalCurve is not a valid curve, or the range of the curve does not intersect with range, or maxDeviation <= 0_m. |
| std::runtime_error | if the curve could not get created. |
|
pure virtual |
C0 Spline from Cubic Bezier control points.
These are 4 control points (P0,P1,P2,P3) for the first segment and 3 control points (P4,P5,P6) for each following segment.
/// p1 = P0 /// t1 = 3(P1-P0) /// p2 = P3 /// t2 = 3(P3-P2) /// /// p1 = P3 /// t1 = 3(P4-P3) /// p2 = P6 /// t2 = 3(P6-P5) ///
etc...
If the wrap type is periodic, the last segment will be closed with the first segment by an additional segment. For this only two additional control points are expected, since the first and last control point are the same.
| controlPoints | A series of points to define the spline. For nonperiodic splines the number of control points n is needed to define (n-4)/3 + 1 segments; for periodic it will be n/3 segments. |
| wrap | Type of wrapping the spline. |
| std::invalid_argument | if the control points are not the right count. |
|
pure virtual |
C1 Spline with Pi'th tangent being: tension * (Pi+1 - Pi-1).
This might match well with paths on top of terrains. The tangents at start and end are tension * (P1 - P0) and tension * (Pn - Pn-1) respectively.
| controlPoints | A series of points to be connected by the spline. |
| tension | Streching value for the tangent's cubic overshoot. Must be > 0. |
| wrap | Type of wrapping the spline. If WrapTypes::periodic, the first and last control point will be connected by an additional segment. |
| std::invalid_argument | if there are less then two control points. |
| std::invalid_argument | if tension <= 0. |
|
pure virtual |
C1 Spline with Pi'th tangent being: tension * (Pi+1 - Pi-1).Length() * Ti.
Modified Catmull-Rom for known tangent directions.
| controlPoints | A series of points and tangents to be connected by the spline. |
| tension | Streching value for the tangent's cubic overshoot. Must be > 0. |
| wrap | Type of wrapping the spline. If WrapTypes::periodic, the first and last control point will be connected by an additional segment. |
| std::invalid_argument | if there are less then two control points. |
| std::invalid_argument | if tension <= 0. |
|
pure virtual |
| idx | id of the control point to retrieve [0,CountControlPoints()[. |
| std::out_of_range | if idx is out of range. |
| std::logic_error | if the spline wasn't created before. |
|
pure virtual |
| idx | id of the control point to retrieve [0,CountControlPoints()[. |
| std::out_of_range | if idx is out of range. |
|
pure virtual |
Resets a control point.
The methods will change the controlpoint only. Any property achieved by using specially interpolated data sets might get lost.
| idx | id of the control point to reset [0,CountControlPoints()[. |
| controlPointAndTangent | 3D position and tangent including cubic overshoot. |
| std::logic_error | if the spline wasn't created before. |
| std::out_of_range | if idx is out of range. |
|
pure virtual |
Transforms the Spline to one with the given parameter range.
Shortens the curve in a way that it will run from the starting point of toRange to the end along the same path as the original, but with parameters running between {0_m,toRange.Length()}.
| toRange | Parameter range of the original Spline, to transform the Spline to. If toRange is outside the original range it will get clipped. |
| std::invalid_argument | if the creation of the shorter spline fails. |
|
pure virtual |
The index of the control point that is the first one to have greater parameter than s.
The index might become greater than CountControlPoints() - 1, in what case s is beyond the curves range.