"L. Spiro Engine"
|
00001 00017 #ifndef __LSM_RECT2_H__ 00018 #define __LSM_RECT2_H__ 00019 00020 #include "../LSMMathLib.h" 00021 #include "../Vector/LSMVector2.h" 00022 00023 namespace lsm { 00024 00030 class CRect2 { 00031 // All is public. This class has no secrets. 00032 public : 00033 // == Various constructors. 00034 LSE_INLINE LSE_CALLCTOR CRect2(); 00035 LSE_INLINE LSE_CALLCTOR CRect2( LSREAL _fX0, LSREAL _fX1, 00036 LSREAL _fY0, LSREAL _fY1 ); 00037 00038 00039 // == Functions. 00045 LSE_INLINE LSREAL LSE_FCALL SizeX() const; 00046 00052 LSE_INLINE LSREAL LSE_FCALL SizeY() const; 00053 00059 LSE_INLINE CVector2 LSE_FCALL Size() const; 00060 00064 LSE_INLINE LSVOID LSE_FCALL Clear(); 00065 00069 LSE_INLINE LSVOID LSE_FCALL NegativeBox(); 00070 00076 LSE_INLINE LSVOID LSE_FCALL EnclosePoint( const CVector2 &_vPoint ); 00077 00083 LSE_INLINE LSVOID LSE_FCALL EncloseBox( const CRect2 &_rRect ); 00084 00085 00086 // == Members. 00090 LSREAL x0, x1; 00091 00095 LSREAL y0, y1; 00096 }; 00097 00098 00099 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00100 // DEFINITIONS 00101 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 00102 // == Various constructors. 00103 LSE_INLINE LSE_CALLCTOR CRect2::CRect2() { 00104 } 00105 LSE_INLINE LSE_CALLCTOR CRect2::CRect2( LSREAL _fX0, LSREAL _fX1, 00106 LSREAL _fY0, LSREAL _fY1 ) { 00107 x0 = _fX0, x1 = _fX1; 00108 y0 = _fY0, y1 = _fY1; 00109 } 00110 00111 00112 // == Functions. 00118 LSE_INLINE LSREAL LSE_FCALL CRect2::SizeX() const { return x1 - x0; } 00119 00125 LSE_INLINE LSREAL LSE_FCALL CRect2::SizeY() const { return y1 - y0; } 00126 00132 LSE_INLINE CVector2 LSE_FCALL CRect2::Size() const { return CVector2( SizeX(), SizeY() ); } 00133 00137 LSE_INLINE LSVOID LSE_FCALL CRect2::Clear() { 00138 x0 = x1 = y0 = y1 = LSM_ZERO; 00139 } 00140 00144 LSE_INLINE LSVOID LSE_FCALL CRect2::NegativeBox() { 00145 x0 = y0 = LSM_INFINITY; 00146 x1 = y1 = -LSM_INFINITY; 00147 } 00148 00154 LSE_INLINE LSVOID LSE_FCALL CRect2::EnclosePoint( const CVector2 &_vPoint ) { 00155 x0 = CMathLib::Min( x0, _vPoint.x ); 00156 x1 = CMathLib::Max( x1, _vPoint.x ); 00157 y0 = CMathLib::Min( y0, _vPoint.y ); 00158 y1 = CMathLib::Max( y1, _vPoint.y ); 00159 } 00160 00166 LSE_INLINE LSVOID LSE_FCALL CRect2::EncloseBox( const CRect2 &_rRect ) { 00167 x0 = CMathLib::Min( x0, _rRect.x0 ); 00168 x1 = CMathLib::Max( x1, _rRect.x1 ); 00169 y0 = CMathLib::Min( y0, _rRect.y0 ); 00170 y1 = CMathLib::Max( y1, _rRect.y1 ); 00171 } 00172 00173 } // namespace lsm 00174 00175 #endif // __LSM_RECT2_H__