Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Segment Class Reference

#include <IceSegment.h>

Inheritance diagram for Segment:
LSS

Public Member Functions

inline_ Segment ()
 Constructor. More...
 
inline_ Segment (const Point &p0, const Point &p1)
 Constructor. More...
 
inline_ Segment (const Segment &seg)
 Copy constructor. More...
 
inline_ ~Segment ()
 Destructor. More...
 
inline_ const PointGetOrigin () const
 
inline_ Point ComputeDirection () const
 
inline_ void ComputeDirection (Point &dir) const
 
inline_ float ComputeLength () const
 
inline_ float ComputeSquareLength () const
 
inline_ void SetOriginDirection (const Point &origin, const Point &direction)
 
inline_ void ComputePoint (Point &pt, float t) const
 
float SquareDistance (const Point &point, float *t=null) const
 
inline_ float Distance (const Point &point, float *t=null) const
 

Public Attributes

Point mP0
 Start of segment. More...
 
Point mP1
 End of segment. More...
 

Detailed Description

Segment class. A segment is defined by S(t) = mP0 * (1 - t) + mP1 * t, with 0 <= t <= 1 Alternatively, a segment is S(t) = Origin + t * Direction for 0 <= t <= 1. Direction is not necessarily unit length. The end points are Origin = mP0 and Origin + Direction = mP1.

Author
Pierre Terdiman
Version
1.0

Definition at line 15 of file IceSegment.h.

Constructor & Destructor Documentation

inline_ Segment::Segment ( )
inline

Constructor.

Definition at line 19 of file IceSegment.h.

19 {}
inline_ Segment::Segment ( const Point p0,
const Point p1 
)
inline

Constructor.

Definition at line 21 of file IceSegment.h.

21 : mP0(p0), mP1(p1) {}
inline_ Segment::Segment ( const Segment seg)
inline

Copy constructor.

Definition at line 23 of file IceSegment.h.

23 : mP0(seg.mP0), mP1(seg.mP1) {}
inline_ Segment::~Segment ( )
inline

Destructor.

Definition at line 25 of file IceSegment.h.

25 {}

Member Function Documentation

inline_ Point Segment::ComputeDirection ( ) const
inline

Definition at line 28 of file IceSegment.h.

Referenced by OPC_SegmentOBBSqrDist(), OPC_SegmentSegmentSqrDist(), and OPC_SegmentTriangleSqrDist().

28 { return mP1 - mP0; }
inline_ void Segment::ComputeDirection ( Point dir) const
inline

Definition at line 29 of file IceSegment.h.

29 { dir = mP1 - mP0; }
inline_ float Segment::ComputeLength ( ) const
inline

Definition at line 30 of file IceSegment.h.

30 { return mP1.Distance(mP0); }
inline_ void Segment::ComputePoint ( Point pt,
float  t 
) const
inline

Computes a point on the segment

Parameters
pt[out] point on segment
t[in] point's parameter [t=0 => pt = mP0, t=1 => pt = mP1]

Definition at line 46 of file IceSegment.h.

46 { pt = mP0 + t * (mP1 - mP0); }
inline_ float Segment::ComputeSquareLength ( ) const
inline

Definition at line 31 of file IceSegment.h.

31 { return mP1.SquareDistance(mP0); }
inline_ float Segment::Distance ( const Point point,
float t = null 
) const
inline

Definition at line 49 of file IceSegment.h.

49 { return sqrtf(SquareDistance(point, t)); }
inline_ const Point& Segment::GetOrigin ( ) const
inline

Definition at line 27 of file IceSegment.h.

Referenced by OPC_SegmentOBBSqrDist(), and OPC_SegmentTriangleSqrDist().

27 { return mP0; }
inline_ void Segment::SetOriginDirection ( const Point origin,
const Point direction 
)
inline

Definition at line 33 of file IceSegment.h.

34  {
35  mP0 = mP1 = origin;
36  mP1 += direction;
37  }
float Segment::SquareDistance ( const Point point,
float t = null 
) const

Member Data Documentation

Point Segment::mP0

Start of segment.

Definition at line 51 of file IceSegment.h.

Referenced by OPC_SegmentOBBSqrDist(), and OPC_SegmentSegmentSqrDist().

Point Segment::mP1

End of segment.

Definition at line 52 of file IceSegment.h.

Referenced by OPC_SegmentOBBSqrDist().


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