Kaim::PositionOnPath Class Reference

Kaim::PositionOnPath Class Reference

#include <positiononpath.h>

Class Description

This class aggregates all necessary information about a position on a Path, namely:

Main API Functions

 PositionOnPath ()
 
bool operator== (const PositionOnPath &positionOnPath) const
 
bool operator!= (const PositionOnPath &positionOnPath) const
 
void InitOnPathNode (Path *path, KyUInt32 pathNodeIdx)
 
void InitOnPathFirstNode (Path *path)
 
void InitOnPathLastNode (Path *path)
 
void InitOnPathEdge (Path *path, const Vec3f &positionOnEdge, KyUInt32 pathEdgeIdx)
 
void Clear ()
 
bool IsValid () const
 
bool IsAtFirstNodeOfPath () const
 
bool IsAtLastNodeOfPath () const
 
bool IsAtFirstEdgeOfPath () const
 
bool IsAtLastEdgeOfPath () const
 
bool IsAtLastNodeOfAChannel () const
 
PathGetPath () const
 
const Vec3fGetPosition () const
 
PositionOnPathStatus GetPositionOnPathStatus () const
 
KyFloat32 GetRemainingDistanceToEndOfPath () const
 
PathEdgeType GetPathEdgeType () const
 
PathEdgeType GetEdgeTypeToMoveOnForward () const
 
PathEdgeType GetEdgeTypeToMoveOnBackward () const
 
bool DoesPrecede (const PositionOnPath &other) const
 
bool IsStrictlyBefore (const PositionOnPath &other) const
 

Path Edge Functions

KyUInt32 GetPathEdgeIndex () const
 
KyUInt32 GetEdgeIdxToMoveOnForward () const
 
KyUInt32 GetEdgeIdxToMoveOnBackward () const
 

Move Functions

void MoveForward (KyFloat32 distanceMove)
 
void MoveBackward (KyFloat32 distanceMove)
 
KyFloat32 MoveForward_StopAtPathNode (KyFloat32 distanceMove)
 
KyFloat32 MoveBackward_StopAtPathNode (KyFloat32 distanceMove)
 
void MoveForwardToNextPathNode ()
 
void MoveBackwardToPrevPathNode ()
 
void MoveForwardToNextPathEdge ()
 
void MoveBackwardToPrevPathEdge ()
 
KyFloat32 ComputeDistance (const PositionOnPath &otherPositionOnPath) const
 
KyFloat32 MoveForwardToClosestPositionOnPath (const Vec3f &originalPosition, const PositionOnPath *upToPosOnPath=0)
 

Unsafe Version of Functions

These functions are unsafe in regard to the pre-conditions mentioned in the functions of similar name without the _Unsafe prefix.

KyFloat32 MoveForward_StopAtPathNode_Unsafe (KyFloat32 distanceMove)
 
KyFloat32 MoveBackward_StopAtPathNode_Unsafe (KyFloat32 distanceMove)
 
void MoveForwardToNextPathNode_Unsafe ()
 
void MoveBackwardToPrevPathNode_Unsafe ()
 
void MoveForwardToNextPathEdge_Unsafe ()
 
void MoveBackwardToPrevPathEdge_Unsafe ()
 

For internal use only

void GetRawValues (Path *&path, Vec3f &position, PositionOnPathStatus &onPathStatus, KyUInt32 &currentIndexOnPath, KyFloat32 &distanceToEndOfPath) const
 
void SetRawValues (Path *path, const Vec3f &position, PositionOnPathStatus onPathStatus, KyUInt32 currentIndexOnPath, KyFloat32 distanceToEndOfPath)
 

Member Function Documentation

KyFloat32 Kaim::PositionOnPath::ComputeDistance ( const PositionOnPath otherPositionOnPath) const

Return the distance along the Path from/to the other position.

KyFloat32MAXVAL if the otherPositionOnPath is on a different Path.

bool Kaim::PositionOnPath::DoesPrecede ( const PositionOnPath other) const

Returns true when this PositionOnPath precede or is at same position that the other one.

KyUInt32 Kaim::PositionOnPath::GetEdgeIdxToMoveOnBackward ( ) const
inline

If this in on a Path node, it returns the index of the edge ending at this Path node, else it returns the index of the edge current instance lies on.

Precondition
GetPositionOnPathStatus() != PositionOnPathStatus_Undefined
Current instance must not be at the first node of the Path.
KyUInt32 Kaim::PositionOnPath::GetEdgeIdxToMoveOnForward ( ) const
inline

If this in on a Path node, it returns the index of the edge starting at this Path node, else it returns the index of the edge current instance lies on.

Precondition
GetPositionOnPathStatus() != PositionOnPathStatus_Undefined
Current instance must not be at the last node of the Path.
+ Examples:
PathEdgeType Kaim::PositionOnPath::GetEdgeTypeToMoveOnBackward ( ) const
inline

return the type of the edge given by GetEdgeIdxToMoveOnBackward()

PathEdgeType Kaim::PositionOnPath::GetEdgeTypeToMoveOnForward ( ) const
inline

return the type of the edge given by GetEdgeIdxToMoveOnForward()

KyUInt32 Kaim::PositionOnPath::GetPathEdgeIndex ( ) const
inline

This function has to be used carefully:

  • if this instance is at the first Path node, it returns the first edge index (0),
  • if it is on another Path node, it returns the index of the edge ending at this Path node,
  • else it returns the index of the edge current instance lies on.
    Precondition
    GetPositionOnPathStatus() != PositionOnPathStatus_Undefined
PathEdgeType Kaim::PositionOnPath::GetPathEdgeType ( ) const
inline

This function has to be used carefully, cf. GetPathEdgeIndex()

bool Kaim::PositionOnPath::IsStrictlyBefore ( const PositionOnPath other) const

Returns true when this PositionOnPath strictly precede the other one; returns false if it as as the same position or after.

void Kaim::PositionOnPath::MoveBackward ( KyFloat32  distanceMove)

Main distance-based backward move method: moves the position along distanceMove meters measured on the broken-line.

Precondition
distanceMove >= 0.0f
KyFloat32 Kaim::PositionOnPath::MoveBackward_StopAtPathNode ( KyFloat32  distanceMove)
inline

Atomic move method: moves backward the position on the current Path edge it lays on, up to distanceMove meters.

If the previous Path node is at a distance lower than distanceMove this instance position is set at this Path node, and the distance from initial position to this Path node is returned; else the position is moved for distanceMove meters on the edge it lays on, and distanceMove is returned.

Precondition
distanceMove >= 0.0f
void Kaim::PositionOnPath::MoveBackwardToPrevPathEdge ( )
inline

Atomic forward move method: must be used with lot of care.

Consider using MoveForward method instead, unless you really need to finely control the PositionOnPath move.

Precondition
GetPositionOnPathStatus() != PositionOnPathStatus_Undefined
Current instance must not be at the first node or edge of the Path.
void Kaim::PositionOnPath::MoveBackwardToPrevPathNode ( )
inline

Atomic backward move method: must be used with lot of care.

Consider using MoveBackward method instead, unless you really need to finely control the PositionOnPath move.

void Kaim::PositionOnPath::MoveForward ( KyFloat32  distanceMove)

Main distance-based forward move method: moves the position along distanceMove meters measured on the broken-line.

Precondition
distanceMove >= 0.0f
KyFloat32 Kaim::PositionOnPath::MoveForward_StopAtPathNode ( KyFloat32  distanceMove)
inline

Atomic move method: moves forward the position on the current Path edge it lays on, up to distanceMove meters.

If the next Path node is at a distance lower than distanceMove this instance position is set at this Path node, and the distance from initial position to this Path node is returned; else the position is moved for distanceMove meters on the edge it lays on, and distanceMove is returned.

Precondition
distanceMove >= 0.0f
KyFloat32 Kaim::PositionOnPath::MoveForwardToClosestPositionOnPath ( const Vec3f originalPosition,
const PositionOnPath upToPosOnPath = 0 
)

Move forward to the closest position on path from originalPosition.

Returns the square distance between originalPosition and the positionOnPath

void Kaim::PositionOnPath::MoveForwardToNextPathEdge ( )
inline

Atomic forward move method: must be used with lot of care.

Consider using MoveForward method instead, unless you really need to finely control the PositionOnPath move.

Precondition
GetPositionOnPathStatus() != PositionOnPathStatus_Undefined
Current instance must not be at the last node or edge of the Path.
void Kaim::PositionOnPath::MoveForwardToNextPathNode ( )
inline

Atomic forward move method: must be used with lot of care.

Consider using MoveForward method instead, unless you really need to finely control the PositionOnPath move.


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