00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef FS_MTH_FSREC2_H
00015 #define FS_MTH_FSREC2_H
00016
00017 #if defined(FS_INCLUDE_USERDEFS) // inject user definition file on request
00018 # include <fs/fsUserDefs.h>
00019 #endif
00020
00021 #include "fsVec2.h"
00022
00023 namespace fs { namespace mth {
00024
00026 template <typename T>
00027 class Rec2_T
00028 {
00029 public:
00030
00031
00032
00033 Rec2_T();
00034 Rec2_T(const Vec2_T<T> &p1, const Vec2_T<T> p2);
00035 Rec2_T(T x1, T y1, T x2, T y2);
00036 Rec2_T(const Rec2_T &RHS);
00037
00038
00039
00040 Rec2_T & operator = (const Rec2_T &RHS);
00041
00042
00043
00044 bool operator == (const Rec2_T &RHS) const;
00045 bool operator != (const Rec2_T &RHS) const;
00046
00047
00048
00050 Vec2_T<T> Delta() const;
00051
00052 public:
00053
00054 Vec2_T<T> p1, p2;
00055 };
00056
00057 template <typename T>
00058 inline Rec2_T<T>::Rec2_T()
00059 {
00060 }
00061
00062 template <typename T>
00063 inline Rec2_T<T>::Rec2_T(const Vec2_T<T> &p1, const Vec2_T<T> p2):
00064 p1(p1),
00065 p2(p2)
00066 {
00067 }
00068
00069 template <typename T>
00070 inline Rec2_T<T>::Rec2_T(T x1, T y1, T x2, T y2):
00071 p1(x1, y1),
00072 p2(x2, y2)
00073 {
00074 }
00075
00076 template <typename T>
00077 inline Rec2_T<T>::Rec2_T(const Rec2_T &RHS) : p1(RHS.p1), p2(RHS.p2)
00078 {
00079 }
00080
00081 template <typename T>
00082 inline Rec2_T<T> & Rec2_T<T>::operator = (const Rec2_T &RHS)
00083 {
00084 p1 = RHS.p1;
00085 p2 = RHS.p2;
00086 return *this;
00087 }
00088
00089 template <typename T>
00090 inline bool Rec2_T<T>::operator == (const Rec2_T &RHS) const
00091 {
00092 return p1 == RHS.p1 && p2 == RHS.p2;
00093 }
00094
00095 template <typename T>
00096 inline bool Rec2_T<T>::operator != (const Rec2_T &RHS) const
00097 {
00098 return p1 != RHS.p1 || p2 != RHS.p2;
00099 }
00100
00101 template <typename T>
00102 inline Vec2_T<T> Rec2_T<T>::Delta() const
00103 {
00104 return Vec2_T<T>(p2.x - p1.x, p2.y - p1.y);
00105 }
00106
00107 }}
00108
00109 #endif // FS_MTH_FSREC2_H