Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/ode/ode-0.9/OPCODE/Ice/IceSegment.h @ 216

Last change on this file since 216 was 216, checked in by mathiask, 16 years ago

[Physik] add ode-0.9

File size: 2.6 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2/**
3 *      Contains code for segments.
4 *      \file           IceSegment.h
5 *      \author         Pierre Terdiman
6 *      \date           April, 4, 2000
7 */
8///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9
10///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
11// Include Guard
12#ifndef __ICESEGMENT_H__
13#define __ICESEGMENT_H__
14
15        class ICEMATHS_API Segment
16        {
17                public:
18                //! Constructor
19                inline_                                 Segment()                                                                                                                       {}
20                //! Constructor
21                inline_                                 Segment(const Point& p0, const Point& p1) : mP0(p0), mP1(p1)            {}
22                //! Copy constructor
23                inline_                                 Segment(const Segment& seg) : mP0(seg.mP0), mP1(seg.mP1)                        {}
24                //! Destructor
25                inline_                                 ~Segment()                                                                                                                      {}
26
27                inline_ const   Point&  GetOrigin()                                             const   { return mP0;                                           }
28                inline_                 Point   ComputeDirection()                              const   { return mP1 - mP0;                                     }
29                inline_                 void    ComputeDirection(Point& dir)    const   { dir = mP1 - mP0;                                      }
30                inline_                 float   ComputeLength()                                 const   { return mP1.Distance(mP0);                     }
31                inline_                 float   ComputeSquareLength()                   const   { return mP1.SquareDistance(mP0);       }
32
33                inline_                 void    SetOriginDirection(const Point& origin, const Point& direction)
34                                                                {
35                                                                        mP0 = mP1 = origin;
36                                                                        mP1 += direction;
37                                                                }
38
39                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
40                /**
41                 *      Computes a point on the segment
42                 *      \param          pt      [out] point on segment
43                 *      \param          t       [in] point's parameter [t=0 => pt = mP0, t=1 => pt = mP1]
44                 */
45                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
46                inline_                 void    ComputePoint(Point& pt, float t)        const   {       pt = mP0 + t * (mP1 - mP0);             }
47
48                                                float   SquareDistance(const Point& point, float* t=null)       const;
49                inline_                 float   Distance(const Point& point, float* t=null)                     const                   { return sqrtf(SquareDistance(point, t));       }
50
51                                                Point   mP0;            //!< Start of segment
52                                                Point   mP1;            //!< End of segment
53        };
54
55#endif // __ICESEGMENT_H__
Note: See TracBrowser for help on using the repository browser.