AGX Dynamics 2.41.1.2
Loading...
Searching...
No Matches
agxUtil::PointCurve< T > Class Template Reference

Utility class curve defined by a set of points. More...

#include <PointCurve.h>

Classes

struct  Segment
 Segment data with begin and end point. More...
 
struct  SegmentationResult
 Result data of segmentation, PointCurve::findSegmentLength. More...
 
struct  SegmentPoint
 Segment point with current curve segment and a point on that segment with local and global time. More...
 

Public Types

using container_type = agx::Vector< value_type >
 
using SegmentationErrorCallback = std::function< agx::Real(const PointCurve &, const SegmentPoint &, const SegmentPoint &, SegmentType)>
 
using SegmentCallback = std::function< void(const Segment &, SegmentType)>
 
using SegmentPointCallback = std::function< void(const SegmentPoint &, const SegmentPoint &, SegmentType)>
 
using TransformCallback = std::function< void(value_type &)>
 
using value_type = T
 

Public Member Functions

 PointCurve ()
 Default constructor.
 
template<typename ContainerT >
 PointCurve (const ContainerT &container)
 Construct given any container.
 
template<typename ContainerT , typename TransformFunc >
 PointCurve (const ContainerT &container, TransformFunc func)
 Construct given any container and a transform function.
 
template<typename T2 >
void add (const T2 &point)
 Add new point to this curve.
 
agx::Real calculateLength () const
 
SegmentPoint evaluate (agx::Real time) const
 Evaluate at given time.
 
agx::Bool finalize ()
 When all points has been added this method has to be called to collect curve data for efficient manipulation/evaluation.
 
SegmentationResult findSegmentLength (agx::UInt numSegments, SegmentationErrorCallback errorFunction, agx::Real maxError, agx::Real segmentLengthTolerance=agx::Real(1.0E-6), agx::UInt maxNumIterations=100ul) const
 Uses Newton Raphson to minimize the error while dividing this curve into segments.
 
void transform (TransformCallback callback)
 Transform points in this curve.
 
void traverse (SegmentCallback callback) const
 Traverse all segments.
 
void traverse (SegmentPointCallback callback, agx::Real segmentLength, agx::Real tolerance=agx::Real(1.0E-6)) const
 Traverses this curve and invokes callback with a segment of a given segment length.
 

Detailed Description

template<typename T>
class agxUtil::PointCurve< T >

Utility class curve defined by a set of points.

It's possible to iterate this curve point and segment wise. Main purpose is to be able to traverse this curve with a given segment length. It's also possible to find optimal segment length given desired number of segments.

Definition at line 41 of file PointCurve.h.

Member Typedef Documentation

◆ container_type

template<typename T >
using agxUtil::PointCurve< T >::container_type = agx::Vector<value_type>

Definition at line 45 of file PointCurve.h.

◆ SegmentationErrorCallback

template<typename T >
using agxUtil::PointCurve< T >::SegmentationErrorCallback = std::function<agx::Real( const PointCurve&, const SegmentPoint&, const SegmentPoint&, SegmentType )>

Definition at line 98 of file PointCurve.h.

◆ SegmentCallback

template<typename T >
using agxUtil::PointCurve< T >::SegmentCallback = std::function<void( const Segment&, SegmentType )>

Definition at line 96 of file PointCurve.h.

◆ SegmentPointCallback

template<typename T >
using agxUtil::PointCurve< T >::SegmentPointCallback = std::function<void( const SegmentPoint&, const SegmentPoint&, SegmentType )>

Definition at line 97 of file PointCurve.h.

◆ TransformCallback

template<typename T >
using agxUtil::PointCurve< T >::TransformCallback = std::function<void( value_type& )>

Definition at line 95 of file PointCurve.h.

◆ value_type

template<typename T >
using agxUtil::PointCurve< T >::value_type = T

Definition at line 44 of file PointCurve.h.

Constructor & Destructor Documentation

◆ PointCurve() [1/3]

template<typename T >
agxUtil::PointCurve< T >::PointCurve

Default constructor.

Definition at line 205 of file PointCurve.h.

◆ PointCurve() [2/3]

template<typename T >
template<typename ContainerT >
agxUtil::PointCurve< T >::PointCurve ( const ContainerT &  container)

Construct given any container.

The ContainerT::value_type must support cast to agx::Vec3.

Parameters
container- container with points

Definition at line 211 of file PointCurve.h.

◆ PointCurve() [3/3]

template<typename T >
template<typename ContainerT , typename TransformFunc >
agxUtil::PointCurve< T >::PointCurve ( const ContainerT &  container,
TransformFunc  func 
)

Construct given any container and a transform function.

The transform function transforms each ContainerT::value_type to this::value_type.

Parameters
container- container with points
func- transform function

Definition at line 220 of file PointCurve.h.

Member Function Documentation

◆ add()

template<typename T >
template<typename T2 >
void agxUtil::PointCurve< T >::add ( const T2 &  point)

Add new point to this curve.

Note
PointCurve::finalize has to be called when all additional points has been added.
Parameters
point- point to add

Definition at line 228 of file PointCurve.h.

◆ calculateLength()

template<typename T >
agx::Real agxUtil::PointCurve< T >::calculateLength
Returns
the total length of this curve

Definition at line 268 of file PointCurve.h.

◆ evaluate()

template<typename T >
PointCurve< T >::SegmentPoint agxUtil::PointCurve< T >::evaluate ( agx::Real  time) const

Evaluate at given time.

Time = 0 is the first point and time = 1 the last. If time < 0 or time > 1 the point is interpolated from the first or the last segment.

Parameters
time- time along this curve
Returns
segment point data

Definition at line 237 of file PointCurve.h.

References LOGGER_ENDL, and LOGGER_WARNING.

◆ finalize()

template<typename T >
agx::Bool agxUtil::PointCurve< T >::finalize

When all points has been added this method has to be called to collect curve data for efficient manipulation/evaluation.

Returns
true if successfully initialized

Definition at line 278 of file PointCurve.h.

References agx::RealEpsilon.

◆ findSegmentLength()

template<typename T >
PointCurve< T >::SegmentationResult agxUtil::PointCurve< T >::findSegmentLength ( agx::UInt  numSegments,
SegmentationErrorCallback  errorFunction,
agx::Real  maxError,
agx::Real  segmentLengthTolerance = agx::Real( 1.0E-6 ),
agx::UInt  maxNumIterations = 100ul 
) const

Uses Newton Raphson to minimize the error while dividing this curve into segments.

Parameters
numSegments- number of segments to divide this curve into
errorFunction- function which returns the error of each segment
maxError- algorithm is successful when the absolute value of the sum over errorFunction of all segments is less than this value
segmentLengthTolerance- segment length tolerance
maxNumIterations- maximum number of iterations before exiting
Returns
the resulting segment length with minimum error

Definition at line 363 of file PointCurve.h.

References agxUtil::PointCurve< T >::SegmentationResult::error, agxUtil::PointCurve< T >::SegmentationResult::numIterations, agxUtil::PointCurve< T >::SegmentationResult::numSegments, agx::REAL_SQRT_EPSILON, agx::RealEpsilon, and agxUtil::PointCurve< T >::SegmentationResult::segmentLength.

◆ transform()

template<typename T >
void agxUtil::PointCurve< T >::transform ( TransformCallback  callback)

Transform points in this curve.

Finalize will be executed after all points has been transformed.

Definition at line 298 of file PointCurve.h.

◆ traverse() [1/2]

template<typename T >
void agxUtil::PointCurve< T >::traverse ( SegmentCallback  callback) const

Traverse all segments.

Parameters
callback- function to call for each segment

◆ traverse() [2/2]

template<typename T >
void agxUtil::PointCurve< T >::traverse ( SegmentPointCallback  callback,
agx::Real  segmentLength,
agx::Real  tolerance = agx::Real(1.0E-6) 
) const

Traverses this curve and invokes callback with a segment of a given segment length.

Note that the curve might be longer or shorter at the end.

Parameters
callback- callback with two SegmentPoint defining a segment of length segmentLength
segmentLength- Length of the segment
tolerance- segment length tolerance

The documentation for this class was generated from the following file: