Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
trax::Cubic Struct Referenceabstract

Cubic polynom curve. More...

#include <C:/Trend/Development/Trax3/Code/trax/Curve.h>

Inheritance diagram for trax::Cubic:

Public Types

using Data = CubicData
 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 spat::Vector< LengthCubicOvershootAt (Length s) const noexcept=0
 Gets the first derivative (with respect to the internal parameter u) of the Cubic function at arc length s. Note that you can not use this vector to create a shortened Cubic. Use Shorten() and/or the Data::CubicOvershootAt() methods instead.
virtual common::Interval< LengthShorten (common::Interval< Length > toRange)=0
 Transforms the Cubic to one with the given parameter range.
virtual const DataGetData () const noexcept=0
 Retrieves the data to construct this curve type. A roundtrip is guaranteed to be invariant.
Creation
virtual common::Interval< LengthCreate (const spat::VectorBundle< Length, Length > &start, const spat::VectorBundle< Length, Length > &end)=0
 Create the Cubic.
virtual common::Interval< LengthCreateBezier (const spat::Position< Length > &P0, const spat::Position< Length > &P1, const spat::Position< Length > &P2, const spat::Position< Length > &P3)=0
 Cubic from Cubic Bezier control points.
virtual std::pair< common::Interval< Length >, LengthCreate (const Curve &originalCurve, common::Interval< Length > range, Length maxDeviation=epsilon__length)=0
 Create the Cubic as approximation of an original curve.
virtual common::Interval< LengthCreate (const Data &data)=0
 Create the Cubic from data set for wich 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< LengthZeroSet () const =0
 Returns a list of parameters at which the normal vector flips from one side to the other.
virtual common::Interval< LengthRange () const =0
virtual spat::Vector< OneLocalUp () 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, OneGetCurveLocalTransformation () 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< CubicMake () noexcept
 Makes a Cubic object.

Additional Inherited Members

Protected Member Functions inherited from trax::Curve
 Curve (const Curve &)=default

Detailed Description

Cubic polynom curve.

The cubic polynom: p(u) = a + b*u + c*u² + d*u³ in general has one solution for the boundary value problem that the starting and ending point and tangents are fixed. It goes like this:

/// u: parameter running from 0 to 1
/// p1,t1: starting point and tangent.
/// p2,t2: ending point and tangent.
/// p(u) = a + b*u + c*u² + d*u³: cubic equation.
/// t(u) = b + 2*c*u + 3*d*u²: first derivative of cubic equation.
///
/// p1 = p(0) = a               (1)
/// p2 = p(1) = a + b + c + d   (2)
/// t1 = t(0) = b               (3)
/// t2 = t(1) = b + 2c + 3d     (4)
///
/// (4)-3*(2)   => t2-3p2 = -3a - 2b - c
///             => c = 3p2 -t2 - 3a - 2b
///             => c = 3p2 -t2 - 3p1 - 2t1 (1),(3)
/// (2)         => d = p2 - p1 - t1 - (3p2 -t2 - 3p1 - 2t1)
///             =>   = 2p1 + t1 - 2p2 + t2
/// 

The above curve will get parametrized by its arc length.

Member Function Documentation

◆ Create() [1/3]

virtual std::pair< common::Interval< Length >, Length > trax::Cubic::Create ( const Curve & originalCurve,
common::Interval< Length > range,
Length maxDeviation = epsilon__length )
pure virtual

Create the Cubic as approximation of an original curve.

The Cubic will be created in a way that it will run from the starting point to the ending point of the range. It is tried to approximate the original curve as good as possible. The maximum aberration is returned by the second std::pair value.

Parameters
originalCurveThe curve to approximate.
rangeThe range on the original curve to approximate.
maxDeviationThe maximum distance between the original curve and the Cubic.
Returns
The total curve range between start and end and the maximum distance between the original curve and the Cubic.
Exceptions
std::invalid_argumentif the creation fails due to malicious input.
std::runtime_errorif the curve could not get created.

◆ Create() [2/3]

virtual common::Interval< Length > trax::Cubic::Create ( const Data & data)
pure virtual

Create the Cubic from data set for wich it is guaranteed, that no calculational drift will happen e.g. in write/read cycles.

Returns
The total curve range between start and end.
Exceptions
std::invalid_argumentif the creation fails.

◆ Create() [3/3]

virtual common::Interval< Length > trax::Cubic::Create ( const spat::VectorBundle< Length, Length > & start,
const spat::VectorBundle< Length, Length > & end )
pure virtual

Create the Cubic.

Parameters
startPosition and tangent (including overshoot) at starting point.
endPosition and tangent (including overshoot) at end point.
Returns
The total curve range between start and end.
Exceptions
std::invalid_argumentif the creation fails.

◆ CreateBezier()

virtual common::Interval< Length > trax::Cubic::CreateBezier ( const spat::Position< Length > & P0,
const spat::Position< Length > & P1,
const spat::Position< Length > & P2,
const spat::Position< Length > & P3 )
pure virtual

Cubic from Cubic Bezier control points.

These are 4 control points (P0,P1,P2,P3) p1 = P0 t1 = 3(P1-P0) p2 = P3 t2 = 3(P3-P2)

◆ Shorten()

virtual common::Interval< Length > trax::Cubic::Shorten ( common::Interval< Length > toRange)
pure virtual

Transforms the Cubic 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()}.

Parameters
toRangeParameter range of the original Cubic, to transform the Cubic to. If toRange is outside the original range it will get clipped.
Returns
{0_m,toRange.Length()}, the new parameter range.
Exceptions
std::invalid_argumentif the creation of the shorter cubic fails.

The documentation for this struct was generated from the following file:
  • C:/Trend/Development/Trax3/Code/trax/Curve.h