|
AGX Dynamics 2.41.1.2
|
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. | |
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.
| using agxUtil::PointCurve< T >::container_type = agx::Vector<value_type> |
Definition at line 45 of file PointCurve.h.
| using agxUtil::PointCurve< T >::SegmentationErrorCallback = std::function<agx::Real( const PointCurve&, const SegmentPoint&, const SegmentPoint&, SegmentType )> |
Definition at line 98 of file PointCurve.h.
| using agxUtil::PointCurve< T >::SegmentCallback = std::function<void( const Segment&, SegmentType )> |
Definition at line 96 of file PointCurve.h.
| using agxUtil::PointCurve< T >::SegmentPointCallback = std::function<void( const SegmentPoint&, const SegmentPoint&, SegmentType )> |
Definition at line 97 of file PointCurve.h.
| using agxUtil::PointCurve< T >::TransformCallback = std::function<void( value_type& )> |
Definition at line 95 of file PointCurve.h.
| using agxUtil::PointCurve< T >::value_type = T |
Definition at line 44 of file PointCurve.h.
| agxUtil::PointCurve< T >::PointCurve |
Default constructor.
Definition at line 205 of file PointCurve.h.
| agxUtil::PointCurve< T >::PointCurve | ( | const ContainerT & | container | ) |
Construct given any container.
The ContainerT::value_type must support cast to agx::Vec3.
| container | - container with points |
Definition at line 211 of file PointCurve.h.
| 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.
| container | - container with points |
| func | - transform function |
Definition at line 220 of file PointCurve.h.
Add new point to this curve.
| point | - point to add |
Definition at line 228 of file PointCurve.h.
| agx::Real agxUtil::PointCurve< T >::calculateLength |
Definition at line 268 of file PointCurve.h.
| 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.
| time | - time along this curve |
Definition at line 237 of file PointCurve.h.
References LOGGER_ENDL, and LOGGER_WARNING.
| 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.
Definition at line 278 of file PointCurve.h.
References agx::RealEpsilon.
| 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.
| 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 |
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.
| 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.
| void agxUtil::PointCurve< T >::traverse | ( | SegmentCallback | callback | ) | const |
Traverse all segments.
| callback | - function to call for each segment |
| 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.
| callback | - callback with two SegmentPoint defining a segment of length segmentLength |
| segmentLength | - Length of the segment |
| tolerance | - segment length tolerance |