aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ode-0.9/OPCODE/Ice/IceSegment.h
diff options
context:
space:
mode:
authordan miller2007-10-19 05:24:38 +0000
committerdan miller2007-10-19 05:24:38 +0000
commitf205de7847da7ae1c10212d82e7042d0100b4ce0 (patch)
tree9acc9608a6880502aaeda43af52c33e278e95b9c /libraries/ode-0.9/OPCODE/Ice/IceSegment.h
parenttrying to fix my screwup part deux (diff)
downloadopensim-SC-f205de7847da7ae1c10212d82e7042d0100b4ce0.zip
opensim-SC-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.gz
opensim-SC-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.bz2
opensim-SC-f205de7847da7ae1c10212d82e7042d0100b4ce0.tar.xz
from the start... checking in ode-0.9
Diffstat (limited to 'libraries/ode-0.9/OPCODE/Ice/IceSegment.h')
-rw-r--r--libraries/ode-0.9/OPCODE/Ice/IceSegment.h55
1 files changed, 55 insertions, 0 deletions
diff --git a/libraries/ode-0.9/OPCODE/Ice/IceSegment.h b/libraries/ode-0.9/OPCODE/Ice/IceSegment.h
new file mode 100644
index 0000000..8d66322
--- /dev/null
+++ b/libraries/ode-0.9/OPCODE/Ice/IceSegment.h
@@ -0,0 +1,55 @@
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__