00001 00005 00006 #ifndef _H_IMG_Line 00007 #define _H_IMG_Line 00008 00009 #include "IMG_Types.h" 00010 #include <math.h> 00011 00018 00019 class IMG_Line { 00020 public: 00021 00029 IMG_Line(TInt32 xs=0, TInt32 ys=0, TInt32 xe=0, TInt32 ye=0) 00030 : m_xs(xs), m_ys(ys), m_xe(xe), m_ye(ye) {} 00031 00036 IMG_Line(const IMG_Line& l) 00037 : m_xs(l.m_xs), m_ys(l.m_ys), m_xe(l.m_xe), m_ye(l.m_ye) {} 00038 00042 virtual ~IMG_Line() {}; 00043 00048 virtual inline float getLength() const; 00049 00057 virtual inline void set(TInt32 xs, TInt32 ys, TInt32 xe, TInt32 ye); 00058 00064 virtual inline bool isEmpty() const; 00065 00073 virtual inline void getPoint(float t, TInt32& x, TInt32& y) const; 00074 00076 TInt32 m_xs; 00078 TInt32 m_ys; 00080 TInt32 m_xe; 00082 TInt32 m_ye; 00083 }; 00084 00085 00086 inline float IMG_Line::getLength() const 00087 { 00088 TInt32 dx = m_xe - m_xs; 00089 TInt32 dy = m_ye - m_ys; 00090 return ((float)::sqrt(((float)dx)*dx + ((float)dy)*dy)); 00091 } 00092 00093 00094 inline void IMG_Line::set(TInt32 xs, TInt32 ys, TInt32 xe, TInt32 ye) 00095 { 00096 m_xs = xs; m_ys = ys; m_xe = xe; m_ye = ye; 00097 } 00098 00099 00100 inline bool IMG_Line::isEmpty() const 00101 { 00102 return (getLength() <= 0); 00103 } 00104 00105 00106 inline void IMG_Line::getPoint(float t, TInt32& x, TInt32& y) const 00107 { 00108 x = (TInt32) (((float)m_xs) + (t * (m_xe - m_xs))); 00109 y = (TInt32) (((float)m_ys) + (t * (m_ye - m_ys))); 00110 } 00111 00112 00113 #endif // _H_IMG_Line