Trax3 3.1.0
trax track library
Loading...
Searching...
No Matches
Track.h File Reference

Home of the Track and TrackBuilder interfaces. More...

#include "IDType.h"
#include "Units.h"
#include "Identified.h"
#include "Orientation.h"
#include "RoadwayTwist.h"
#include "common/Interval.h"
#include "spat/Box.h"
#include "spat/Frame.h"
#include "spat/Vector2D.h"
#include "spat/VectorBundle.h"
#include "spat/VectorBundle2.h"
Include dependency graph for Track.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  trax::Track
 Interface for a track used to calculate 3D positions. More...
struct  trax::Track::End
 Designates an end at a specific track. More...
struct  trax::Track::Coupling
 Designates two track ends. Typically used for coupling relations. More...
struct  trax::Track::Overlap
 Overlapping data. More...
struct  trax::TrackBuilder
 Interface for making and shaping tracks. More...

Namespaces

namespace  trax
 Namespace of all the trax track libraries classes and methods.

Functions

dclspc const char * trax::ToString (Track::TrackType type)
 Converts a TrackType to readable string.
dclspc Track::TrackType trax::TrackType (const std::string &type) noexcept
 Finds TrackType for string.
bool trax::operator== (const Track::End &theone, const Track::End &theother) noexcept
 Tests for equality.
bool trax::operator!= (const Track::End &theone, const Track::End &theother) noexcept
 Tests for inequality.
bool trax::operator== (const Track::Coupling &theone, const Track::Coupling &theother) noexcept
 Tests for equality.
bool trax::operator!= (const Track::Coupling &theone, const Track::Coupling &theother) noexcept
 Tests for inequality.
bool trax::operator== (const Track::Overlap &a, const Track::Overlap &b) noexcept
bool trax::operator< (const Track::Overlap &a, const Track::Overlap &b) noexcept
dclspc std::string trax::ToString (Track::EndType end)
 Makes a string from the status.
dclspc Track::EndType trax::ToEndType (const std::string &end)
 Makes a status value from a status string.
Track::EndType trax::operator! (Track::EndType end) noexcept
dclspc Length trax::Segment (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Calculates a segment length ds so that the visible failure in a track would become smaller than some marginal distance of e.
dclspc Length trax::Segment (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Works like the first overload, but takes the dimensions of the track model into account.
dclspc Length trax::Segment_Checked (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Works like Segment(), but checks the result and shrinks it if necessary.
dclspc Length trax::Segment_Checked (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Works like the first overload, but takes the dimensions of the track model into account.
dclspc Length trax::Segment_TotallyChecked (const Track &track, Length s, Length e, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Works like Segment(), but checks the result.
dclspc Length trax::Segment_TotallyChecked (const Track &track, Length s, Length e, Length w, Length h, common::Interval< Length > segmentLimits, bool ignoreCuvesTorsion=false)
 Works like the first overload, but takes the dimensions of the track model. into account.
dclspc std::pair< bool, Lengthtrax::Foot (const spat::Position< Length > &ofPoint, const Track &toTrack)
 Foot for point in space.
dclspc std::pair< bool, Lengthtrax::Foot (const spat::Position< Length > &ofPoint, const Track &toTrack, Length bestGuess)
dclspc std::pair< bool, Lengthtrax::Foot (const spat::Position< Length > &ofPoint, const Track &toTrack, Length bestGuess, common::Interval< Length > inRange)
dclspc std::pair< bool, Lengthtrax::Foot (const spat::VectorBundle< Length, One > &ofRay, const Track &toTrack)
 Foot for a ray in space.
dclspc std::pair< bool, Lengthtrax::Foot (const spat::VectorBundle< Length, One > &ofRay, const Track &toTrack, Length bestGuess)
dclspc std::pair< bool, Lengthtrax::Foot (const spat::VectorBundle< Length, One > &ofRay, const Track &toTrack, Length bestGuess, common::Interval< Length > inRange)
dclspc Length trax::Closest (const spat::Position< Length > &toPoint, const Track &onTrack, bool includeEndpoints=true)
 Closest point on a track to a point in space.
dclspc Length trax::Closest (const spat::VectorBundle< Length, One > &toRay, const Track &onTrack, bool includeEndpoints=true)
 Closest point on a track to a ray in space.
dclspc void trax::Couple (std::pair< std::shared_ptr< Track >, Track::EndType > trackA, std::pair< std::shared_ptr< Track >, Track::EndType > trackB)
 Couple this trackA at endA with trackB at endB.
dclspc Length trax::DistanceOf (Track::cTrackEnd trackEndA, Track::cTrackEnd trackEndB)
dclspc Length trax::DistanceToCoupled (const Track &track, Track::EndType atEnd)
dclspc Angle trax::KinkToCoupled (const Track &track, Track::EndType atEnd)
dclspc Angle trax::TwistToCoupled (const Track &track, Track::EndType atEnd)
bool dclspc trax::SetFrame (TrackBuilder &track, const spat::Frame< Length, One > &start, Length s) noexcept
 Same as track.SetFrame( start, s ), but does not throw.
void dclspc trax::TransformToNonEEPCurve (TrackBuilder &track)
 Creates a matching Curve, Twist and Frame from an EEPCurve.
bool dclspc trax::Mirror (TrackBuilder &track, const spat::VectorBundle< Length, One > mirrorPlane, bool bTest=false)
 Mirrors the track's geometry on a plane.
bool dclspc trax::Normalize (TrackBuilder &track, bool bTest=false)
 Normalizes the attached Curve's projected parameter length to the 0_m to track.GetLength() range.
void dclspc trax::StraightenUp (TrackBuilder &track, const spat::Vector< One > &up=Up)
 Some curves maintain a local up direction. It might be pleasing for the user to have his curve straightended up in the sense that this direction alignes with what he thinks is being 'up'.
bool dclspc trax::Simplify (TrackBuilder &track) noexcept
 Simplifies the track's curve.
std::vector< std::shared_ptr< TrackBuilder > > dclspc trax::CloseGap (spat::Frame< Length, One > start, spat::Frame< Length, One > end, common::Interval< Length > limits, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle, bool cloneCurve=false)
 Creates a series of new tracks that close the gap between start and end.
Equip a track by a streched curve.

Creates a most simple curve for the track, so that the endpoints get connected.

A new curve will get created and applied to the track, to make the geometry of the track fit the demand. The different overloads differ in what values of the track ends will be preserved. The methods give the strong guarantee, i.e. they will either succeed or keep the curve of the track untouched.

Parameters
trackTrack to change the curve for.
startstarting position and tangent of the track; length of tangent varies the curve by an overshoot value.
bKeepStartTangentPreserve the start tangent. In this case the cubic overshoot values have to be provided, because a Cubic might get created.
cubicOvershootStartcubic overshoot value at starting point.
cubicOvershootEndcubic overshoot value at ending point.
endending position and tangent of the track; length of tangent varies the curve by an overshoot value.
bKeepEndTangentPreserve the end tangent. In this case the cubic overshoot values have to
length_limitsSpecifies a lower and an upper limit for the track length. If exceeded, the track remains unchanged.
overshoot_limitsSpecifies a lower and an upper limit for the cubic overshoots at the ends of the track. If exceeded, the track remains unchanged.
upVector pointing in up direction. Must be of unit length.
e_lengtherror margin for the positional values.
e_angleerror margin for the directional values. be provided, because a Cubic might get created.
Returns
true if the track was successfully modified, false if streching within the limits for length, overshoot, positional and angular epsilon was not possible.
Exceptions
std::invalid_argumentif no curve could get created, e.g. because start and end are collocated.
bool dclspc trax::Strech (TrackBuilder &track, spat::VectorBundle< Length, One > start, spat::VectorBundle< Length, One > end, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
bool dclspc trax::StrechStart (TrackBuilder &track, spat::Position< Length > start, common::Interval< Length > length_limits={0_m,+infinite__length}, const spat::Vector< One > &up=Up, Length e_length=epsilon__length)
bool dclspc trax::StrechStart (TrackBuilder &track, spat::Position< Length > start, bool bKeepStartTangent, Length cubicOvershootStart, Length cubicOvershootEnd, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
bool dclspc trax::StrechStart (TrackBuilder &track, spat::VectorBundle< Length, One > start, Length cubicOvershootEnd, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
bool dclspc trax::StrechEnd (TrackBuilder &track, spat::Position< Length > end, common::Interval< Length > length_limits={0_m,+infinite__length}, const spat::Vector< One > &up=Up, Length e_length=epsilon__length)
bool dclspc trax::StrechEnd (TrackBuilder &track, spat::Position< Length > end, bool bKeepEndTangent, Length cubicOvershootStart, Length cubicOvershootEnd, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
bool dclspc trax::StrechEnd (TrackBuilder &track, spat::VectorBundle< Length, One > end, Length cubicOvershootStart, common::Interval< Length > length_limits={0_m,+infinite__length}, common::Interval< Length > overshoot_limits={ 0_m,+infinite__length }, const spat::Vector< One > &up=Up, Length e_length=epsilon__length, Angle e_angle=epsilon__angle)
Copying Tracks

Creates a new track with the parameter range copyRange and the same geometry as a template track has inside this range.

The copyRange gets clipped to the original track's range. The first method creates a new track; the second one takes an existing one to make it the copy. This can be used to change the track type (e.g. to movable or paralleizable track).

Parameters
originalTracktemplate track to create the track piece for.
copyTracktarget track to become the track piece.
copyRangeRange of the track to copy. Must have an intersection with the original track's range.
cloneCurveIf true, the copy track gets its own cloned curve, otherwise it shares the original curve.
Returns
the track copy or nullptr if copying was not possible.
std::shared_ptr< TrackBuilder > dclspc trax::CopyTrack (const TrackBuilder &originalTrack, TrackBuilder &copyTrack, bool cloneCurve=false)
 Creates a new track from a template track.
std::shared_ptr< TrackBuilder > dclspc trax::CopyTrack (const TrackBuilder &originalTrack, bool cloneCurve=false)
 Creates a new track from a template track.
std::shared_ptr< TrackBuilder > dclspc trax::CopyTrack (const TrackBuilder &originalTrack, TrackBuilder &copyTrack, common::Interval< Length > copyRange, bool cloneCurve=false)
 Creates a new track from a template track.
std::shared_ptr< TrackBuilder > dclspc trax::CopyTrack (const TrackBuilder &originalTrack, common::Interval< Length > copyRange, bool cloneCurve=false)
 Creates a new track from a template track.
Splitting Tracks

Creates new tracks that follow the same path of a given track.

The tracks will have all the length track.GetLength()/numPieces.

Parameters
tracktemplate track to create the track pieces for.
numPieceshow many new tracks to create.
atParameterParameter value along the track to split at.
cloneCurveIf true, each track gets its own cloned curve, otherwise all the tracks share the original curve.
factoryFactory to be used to create the new tracks.
Returns
a list with newly created consecutive tracks.
std::vector< std::shared_ptr< TrackBuilder > > dclspc trax::SplitTrack (const TrackBuilder &track, int numPieces=2, bool cloneCurve=false)
std::vector< std::shared_ptr< TrackBuilder > > dclspc trax::SplitTrack (const TrackBuilder &track, Length atParameter, bool cloneCurve=false)
Parallel points and tangents to track

Parallel to twisted track.

/// Cp = Fw.P + h * Fw.N + v * Fw.B
/// D1 = dCp(s)/ds = (1 + k * (v*sin(w) - h*cos(w))) * Fw.T - (t + dw/ds) * (v*Fw.N - h*Fw.B);
/// 

where s is the arc length parameter of the original curve, not of the parallel. See traxBook Appendix C.

Returns
A vector bundle, with P being the position on the parallel curve, T being the D1 of the parallel at that point with T.Length() * ds == Parallel_ds (for small ds) and T/T.Length() being the unit tangent of the parallel. N gives the up vector of the original track at s.
spat::VectorBundle2< Length, One > dclspc trax::Parallel (const TrackBuilder &originalTrack, Length s, spat::Vector2D< Length > shift)
 Parallel with respect to some plane, defined by an up-direction.
spat::VectorBundle2< Length, One > dclspc trax::ParallelToUp (const TrackBuilder &originalTrack, Length s, spat::Vector2D< Length > shift, spat::Vector< One > up=Up)
 Parallel with respect to some plane, defined by an up-direction.
Parallel Tracks

Make a parallel track.

Parameters
originalTrackthe original track to make a parallel for.
rangethe range on the original track, to make a parallel for.
shiftthe distance of the parallel to the original. If shift == spat::Null2D it returns a copy of the original track.
bShiftRelativeToTwistOrUpmode of parallelity
minPointDistanceminimum distance for the polygonal or spline vertices along the parallel curve. This might get smaller for the last two segments.
maxDeviationLengthmaximum distance between the true parallel and the polygonal approximation.
upPlane defining vector for plane oriented parallelity mode.
sampleDistanceLimitsThe minimum and maximum distance between the sample points
Returns
The parallel track or nullptr, if it couldn't be built.
Exceptions
std::invalid_argumentif the original track is not valid.
std::runtime_errorif the parallel track could not be built.
std::shared_ptr< TrackBuilder > dclspc trax::MakeParallelTrack (const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, Angle maxDeviationAngle=epsilon__angle)
 Makes a parallel track by trying Line, Arc and Helix first. If that does not apply it returns nullptr.
std::shared_ptr< TrackBuilder > dclspc trax::MakeParallelTrackWithPolygonalChain (const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 10_m })
 Parallel approximation by Polygonal Chain.
std::shared_ptr< TrackBuilder > dclspc trax::MakeParallelTrackWithSampledCurve (const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift=spat::Null2D< trax::Length >, bool bShiftRelativeToTwistOrUp=true, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, Angle maxDeviationAngle=epsilon__angle, common::Interval< Length > sampleDistanceLimits={ epsilon__length, 20_m })
 Parallel approximation by SampledCurve.
std::shared_ptr< TrackBuilder > dclspc trax::MakeParallelTrackWithSpline (const TrackBuilder &originalTrack, common::Interval< Length > range, spat::Vector2D< Length > shift, bool bShiftRelativeToTwistOrUp, spat::Vector< One > up=Up, Length maxDeviationLength=epsilon__length, common::Interval< Length > sampleDistanceLimits={ 1_m, 1000_m })
 Parallel approximation by Spline.

Detailed Description

Home of the Track and TrackBuilder interfaces.