00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef OLENA_CORE_POINT2D_HXX
00029 # define OLENA_CORE_POINT2D_HXX
00030
00031 # include <oln/core/point1d.hh>
00032 # include <oln/core/dpoint2d.hh>
00033 # include <iostream>
00034
00035
00036 namespace oln {
00037
00038 inline
00039 point2d::point2d()
00040 {
00041 nth(0) = 0;
00042 nth(1) = 0;
00043 }
00044
00045 inline
00046 point2d::point2d(coord row, coord col)
00047 {
00048 nth(0) = row;
00049 nth(1) = col;
00050 }
00051
00052 inline
00053 point2d::point2d(const point1d& p, coord row)
00054 {
00055 nth(0) = row;
00056 nth(1) = p.col();
00057 }
00058
00059 inline coord
00060 point2d::row() const
00061 {
00062 return nth(0);
00063 }
00064
00065 inline coord&
00066 point2d::row()
00067 {
00068 return nth(0);
00069 }
00070
00071 inline coord
00072 point2d::col() const
00073 {
00074 return nth(1);
00075 }
00076
00077 inline coord&
00078 point2d::col()
00079 {
00080 return nth(1);
00081 }
00082
00083 inline point2d&
00084 point2d::plus_assign_dp(const dpoint2d& dp)
00085 {
00086 row() += dp.row();
00087 col() += dp.col();
00088 return *this;
00089 }
00090
00091 inline point2d&
00092 point2d::minus_assign_dp(const dpoint2d& dp)
00093 {
00094 row() -= dp.row();
00095 col() -= dp.col();
00096 return *this;
00097 }
00098
00099 inline dpoint2d
00100 point2d::minus_p(const point2d& p) const
00101 {
00102 dpoint2d dp(row() - p.row(), col() - p.col());
00103 return dp;
00104 }
00105
00106 inline point2d
00107 point2d::plus_dp(const dpoint2d& dp) const
00108 {
00109 point2d p = *this;
00110 p += dp;
00111 return p;
00112 }
00113
00114 inline point2d
00115 point2d::minus_dp(const dpoint2d& dp) const
00116 {
00117 point2d p = *this;
00118 p -= dp;
00119 return p;
00120 }
00121
00122 inline point2d
00123 point2d::minus() const
00124 {
00125 point2d p(-row(), -col());
00126 return p;
00127 }
00128
00129
00130 }
00131
00132
00133 inline std::ostream&
00134 operator<<(std::ostream& o, const oln::point2d& p)
00135 {
00136 return o << '(' << p.row() << ',' << p.col() << ')';
00137 }
00138
00139
00140
00141 #endif // ! OLENA_CORE_POINT2D_HXX