diff options
author | FWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544> | 2011-12-08 14:53:40 +0000 |
---|---|---|
committer | FWoltermann@gmail.com <FWoltermann@gmail.com@076cb2c4-205e-83fd-5cf3-1be9aa105544> | 2011-12-08 14:53:40 +0000 |
commit | e33e19d0587146859d48a134ec9fd94e7b7ba5cd (patch) | |
tree | 69d048c8801858d2756ab3a487090a7a1b74bf14 /Opcode/Ice/IceSegment.h | |
download | starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.zip starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.gz starshatter-e33e19d0587146859d48a134ec9fd94e7b7ba5cd.tar.bz2 |
Initial upload
Diffstat (limited to 'Opcode/Ice/IceSegment.h')
-rw-r--r-- | Opcode/Ice/IceSegment.h | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Opcode/Ice/IceSegment.h b/Opcode/Ice/IceSegment.h new file mode 100644 index 0000000..3dc8314 --- /dev/null +++ b/Opcode/Ice/IceSegment.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/**
+ * Contains code for segments.
+ * \file IceSegment.h
+ * \author Pierre Terdiman
+ * \date April, 4, 2000
+ */
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Include Guard
+#ifndef __ICESEGMENT_H__
+#define __ICESEGMENT_H__
+
+ class ICEMATHS_API Segment
+ {
+ public:
+ //! Constructor
+ inline_ Segment() {}
+ //! Constructor
+ inline_ Segment(const Point& p0, const Point& p1) : mP0(p0), mP1(p1) {}
+ //! Copy constructor
+ inline_ Segment(const Segment& seg) : mP0(seg.mP0), mP1(seg.mP1) {}
+ //! Destructor
+ inline_ ~Segment() {}
+
+ inline_ const Point& GetOrigin() const { return mP0; }
+ inline_ Point ComputeDirection() const { return mP1 - mP0; }
+ inline_ void ComputeDirection(Point& dir) const { dir = mP1 - mP0; }
+ inline_ float ComputeLength() const { return mP1.Distance(mP0); }
+ inline_ float ComputeSquareLength() const { return mP1.SquareDistance(mP0); }
+
+ inline_ void SetOriginDirection(const Point& origin, const Point& direction)
+ {
+ mP0 = mP1 = origin;
+ mP1 += direction;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ /**
+ * Computes a point on the segment
+ * \param pt [out] point on segment
+ * \param t [in] point's parameter [t=0 => pt = mP0, t=1 => pt = mP1]
+ */
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ inline_ void ComputePoint(Point& pt, float t) const { pt = mP0 + t * (mP1 - mP0); }
+
+ float SquareDistance(const Point& point, float* t=null) const;
+ inline_ float Distance(const Point& point, float* t=null) const { return sqrtf(SquareDistance(point, t)); }
+
+ Point mP0; //!< Start of segment
+ Point mP1; //!< End of segment
+ };
+
+#endif // __ICESEGMENT_H__
|