fs/mth/fsRec2.h

Go to the documentation of this file.
00001 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
00002 /*                          _______      ______    ______          __      */
00003 /*  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~    / ____(_)___ / ___ /)  / ____/___  ____/ /__    */
00004 /*      [fsRec2]          / /_  / / __ \\__ \|/  / /   / __ \/ __  / _ \   */
00005 /*       rev. 2          / __/ / / /_/ /__/ /   / /___/ /_/ / /_/ /  __/   */
00006 /*    20th Jan 2007     /_/   /_/ ,___/____/    \____/\____/\__,_/\___/    */
00007 /*     [x] stable              /_/ (c) 2006-7 Filip STOKLAS (FipS)         */
00008 /*  ~ ~ ~ ~ ~ ~ ~ ~ ~ ~       http://HOLE.4FipS.com/fips_code.php          */
00009 /*                                                                         */
00010 /* This code is free for personal and commercial use. You may redistribute */
00011 /* it by any means. If you use the code for your own projects please give  */
00012 /* me credit. Please send a bug report. Don't alter or remove this header! */
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     // --- CONSTRUCTION ---
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     // --- ASSIGMENT ---
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     // --- OPERATIONS ---
00048     
00050     Vec2_T<T> Delta() const;
00051  
00052  public: // direct access is allowed
00053  
00054     Vec2_T<T> p1, p2;
00055 };
00056 //---------------------------------------------------------------------------
00057 template <typename T>
00058 inline Rec2_T<T>::Rec2_T() // does nothing
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 }} // namespace fs::mth
00108 //---------------------------------------------------------------------------
00109 #endif // FS_MTH_FSREC2_H

FipS' Code (Thu Feb 15 22:43:35 2007) - (c) Filip STOKLAS (FipS) - [ www ] [ Guest Book ]