Artificial Intelligence
Public Types | Public Member Functions | Private Attributes

OpenSteer::PolylineSegmentedPath Class Reference

#include <PolylineSegmentedPath.h>

Inheritance diagram for OpenSteer::PolylineSegmentedPath:
OpenSteer::SegmentedPath OpenSteer::Path

List of all members.

Public Types

typedef size_t size_type

Public Member Functions

 PolylineSegmentedPath ()
 PolylineSegmentedPath (size_type numOfPoints, Vec3 const newPoints[], bool closedCycle)
 PolylineSegmentedPath (PolylineSegmentedPath const &other)
virtual ~PolylineSegmentedPath ()
PolylineSegmentedPathoperator= (PolylineSegmentedPath other)
void swap (PolylineSegmentedPath &other)
void setPath (size_type numOfPoints, Vec3 const newPoints[], bool closedCycle)
void movePoints (size_type startIndex, size_type numOfPoints, Vec3 const newPoints[])
virtual bool isValid () const
virtual Vec3 mapPointToPath (const Vec3 &point, Vec3 &tangent, float &outside) const
virtual Vec3 mapPathDistanceToPoint (float pathDistance) const
virtual float mapPointToPathDistance (const Vec3 &point) const
virtual bool isCyclic () const
virtual float length () const
virtual size_type pointCount () const
virtual Vec3 point (size_type pointIndex) const
virtual size_type segmentCount () const
virtual float segmentLength (size_type segmentIndex) const
virtual Vec3 segmentStart (size_type segmentIndex) const
virtual Vec3 segmentEnd (size_type segmentIndex) const
virtual float mapPointToSegmentDistance (size_type segmentIndex, Vec3 const &point) const
virtual Vec3 mapSegmentDistanceToPoint (size_type segmentIndex, float segmentDistance) const
virtual Vec3 mapSegmentDistanceToTangent (size_type segmentIndex, float segmentDistance) const
virtual void mapDistanceToSegmentPointAndTangent (size_type segmentIndex, float distance, Vec3 &pointOnPath, Vec3 &tangent) const
virtual void mapPointToSegmentDistanceAndPointAndTangent (size_type segmentIndex, Vec3 const &point, float &distance, Vec3 &pointOnPath, Vec3 &tangent) const

Private Attributes

std::vector< Vec3points_
std::vector< Vec3segmentTangents_
std::vector< float > segmentLengths_
bool closedCycle_

Detailed Description

Segmented path build by polylines. The last point of the path might be connected to the first point building a closed cycle.


Member Typedef Documentation


Constructor & Destructor Documentation

OpenSteer::PolylineSegmentedPath::PolylineSegmentedPath ( )

Constructs an invalid path. Behavior of most member functions is undefined if a path has less than two distinct points.

OpenSteer::PolylineSegmentedPath::PolylineSegmentedPath ( size_type  numOfPoints,
Vec3 const  newPoints[],
bool  closedCycle 
)

Constructs a new path.

Parameters:
numOfPointsNumber of points. Must be at least two.
newPointsAs many points as indicated by numOfPoints. Two adjacent points mustn't be identical and the first the last point mustn't be identical.
closedCycleIf true the first point of newPoints is copied to the end of the path to represent the cycle closing segment.
OpenSteer::PolylineSegmentedPath::PolylineSegmentedPath ( PolylineSegmentedPath const &  other)
OpenSteer::PolylineSegmentedPath::~PolylineSegmentedPath ( ) [virtual]

Member Function Documentation

bool OpenSteer::PolylineSegmentedPath::isCyclic ( ) const [virtual]

Returns true f the path is closed, otherwise false.

Implements OpenSteer::Path.

bool OpenSteer::PolylineSegmentedPath::isValid ( ) const [virtual]

Returns true if the path is valid, false otherwise.

Implements OpenSteer::Path.

float OpenSteer::PolylineSegmentedPath::length ( ) const [virtual]

Returns the length of the path.

Implements OpenSteer::Path.

void OpenSteer::PolylineSegmentedPath::mapDistanceToSegmentPointAndTangent ( size_type  segmentIndex,
float  distance,
Vec3 pointOnPath,
Vec3 tangent 
) const [virtual]

Combines mapSegmentDistanceToPoint and mapSegmentDistanceToTangent.

Implements OpenSteer::SegmentedPath.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::mapPathDistanceToPoint ( float  pathDistance) const [virtual]

Given a distance along the path, convert it to a point on the path. If isValid is false the behavior is undefined.

Implements OpenSteer::Path.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::mapPointToPath ( const Vec3 point,
Vec3 tangent,
float &  outside 
) const [virtual]

Given an arbitrary point ("A"), returns the nearest point ("P") on this path center line. Also returns, via output arguments, the path tangent at P and a measure of how far A is outside the Pathway's "tube". Note that a negative distance indicates A is inside the Pathway.

If isValid is false the behavior is undefined.

Implements OpenSteer::Path.

float OpenSteer::PolylineSegmentedPath::mapPointToPathDistance ( const Vec3 point) const [virtual]

Given an arbitrary point, convert it to a distance along the path. If isValid is false the behavior is undefined.

Implements OpenSteer::Path.

float OpenSteer::PolylineSegmentedPath::mapPointToSegmentDistance ( size_type  segmentIndex,
Vec3 const &  point 
) const [virtual]

Maps point to the nearest point on the center line of segment segmentIndex and returns the distance from the segment start to this point.

Implements OpenSteer::SegmentedPath.

void OpenSteer::PolylineSegmentedPath::mapPointToSegmentDistanceAndPointAndTangent ( size_type  segmentIndex,
Vec3 const &  point,
float &  distance,
Vec3 pointOnPath,
Vec3 tangent 
) const [virtual]

Combines mapPointToSegmentDistance, mapSegmentDistanceToPoint, and mapSegmentDistanceToTangent.

Implements OpenSteer::SegmentedPath.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::mapSegmentDistanceToPoint ( size_type  segmentIndex,
float  segmentDistance 
) const [virtual]

Maps segmentDistance to the center line of segment segmentIndex and returns the reached point.

If segmentDistance is greater or smaller than the segment length is is clamped to 0.0f or segmentLength().

Implements OpenSteer::SegmentedPath.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::mapSegmentDistanceToTangent ( size_type  segmentIndex,
float  segmentDistance 
) const [virtual]

Maps segmentDistance to the centerline of the segment segmentIndex and returns the tangent of the pathway at the reached point.

If segmentDistance is greater or smaller than the segment length is is clamped to 0.0f or segmentLength().

Implements OpenSteer::SegmentedPath.

void OpenSteer::PolylineSegmentedPath::movePoints ( size_type  startIndex,
size_type  numOfPoints,
Vec3 const  newPoints[] 
)

Replaces numOfPoints points starting at startIndex.

In the resulting sequence of points there mustn't be two adjacent ones that are equal. The first and last point mustn't be identical, too.

If the first point is changed and the path is cyclic the duplication of the first point at the end of the sequence representing the path closing segment is updated automatically.

Parameters:
startIndexFirst point to be moved or replaced.
numOfPointsNumber of points to move or replace. numOfPoints + startIndex must be lesser or equal to pointCount.
newPointsMoved points to replace the old ones.
OpenSteer::PolylineSegmentedPath & OpenSteer::PolylineSegmentedPath::operator= ( PolylineSegmentedPath  other)
OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::point ( size_type  pointIndex) const [virtual]

Returns the point pointIndex.

If the path is cyclic also the last point that is the duplicated first one is accessible.

Implements OpenSteer::SegmentedPath.

OpenSteer::SegmentedPath::size_type OpenSteer::PolylineSegmentedPath::pointCount ( ) const [virtual]

Returns the number of points defining the segments.

This also includes the duplicated first point if the path is cyclic.

Implements OpenSteer::SegmentedPath.

OpenSteer::PolylineSegmentedPath::size_type OpenSteer::PolylineSegmentedPath::segmentCount ( ) const [virtual]

Returns the number of segments that build the pathway.

Implements OpenSteer::SegmentedPath.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::segmentEnd ( size_type  segmentIndex) const [virtual]

Returns the end point of segment segmentIndex.

Implements OpenSteer::SegmentedPath.

float OpenSteer::PolylineSegmentedPath::segmentLength ( size_type  segmentIndex) const [virtual]

Returns the length of segment segmentIndex.

Implements OpenSteer::SegmentedPath.

OpenSteer::Vec3 OpenSteer::PolylineSegmentedPath::segmentStart ( size_type  segmentIndex) const [virtual]

Returns the start point of the segment segmentIndex.

Implements OpenSteer::SegmentedPath.

void OpenSteer::PolylineSegmentedPath::setPath ( size_type  numOfPoints,
Vec3 const  newPoints[],
bool  closedCycle 
)

Replaces all path information by the given ones.

Parameters:
numOfPointsNumber of points. Must be at least two.
newPointsAs many points as indicated by numOfPoints. Two adjacent points mustn't be identical and the first the last point mustn't be identical.
closedCycleIf true the first point of newPoints is copied to the end of the path to represent the cycle closing segment.
void OpenSteer::PolylineSegmentedPath::swap ( PolylineSegmentedPath other)

Member Data Documentation

std::vector< float > OpenSteer::PolylineSegmentedPath::segmentLengths_ [private]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines