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_POINT3D_HXX
00029 # define OLENA_CORE_POINT3D_HXX
00030
00031 # include <oln/core/point2d.hh>
00032 # include <oln/core/dpoint3d.hh>
00033 # include <iostream>
00034
00035
00036 namespace oln {
00037
00038
00039 inline
00040 point3d::point3d()
00041 {
00042 nth(0) = 0;
00043 nth(1) = 0;
00044 nth(2) = 0;
00045 }
00046
00047 inline
00048 point3d::point3d(coord slice, coord row, coord col)
00049 {
00050 nth(0) = slice;
00051 nth(1) = row;
00052 nth(2) = col;
00053 }
00054
00055 inline
00056 point3d::point3d(const point2d& p, coord slice)
00057 {
00058 nth(0) = slice;
00059 nth(1) = p.row();
00060 nth(2) = p.col();
00061 }
00062
00063 inline coord
00064 point3d::slice() const
00065 {
00066 return nth(0);
00067 }
00068
00069 inline coord&
00070 point3d::slice()
00071 {
00072 return nth(0);
00073 }
00074
00075 inline coord
00076 point3d::row() const
00077 {
00078 return nth(1);
00079 }
00080
00081 inline coord&
00082 point3d::row()
00083 {
00084 return nth(1);
00085 }
00086
00087 inline coord
00088 point3d::col() const
00089 {
00090 return nth(2);
00091 }
00092
00093 inline coord&
00094 point3d::col()
00095 {
00096 return nth(2);
00097 }
00098
00099 inline point3d&
00100 point3d::plus_assign_dp(const dpoint3d& dp)
00101 {
00102 slice() += dp.slice();
00103 row() += dp.row();
00104 col() += dp.col();
00105 return *this;
00106 }
00107
00108 inline point3d&
00109 point3d::minus_assign_dp(const dpoint3d& dp)
00110 {
00111 slice() -= dp.slice();
00112 row() -= dp.row();
00113 col() -= dp.col();
00114 return *this;
00115 }
00116
00117 inline dpoint3d
00118 point3d::minus_p(const point3d& p) const
00119 {
00120 dpoint3d dp(slice() - p.slice(),
00121 row() - p.row(),
00122 col() - p.col());
00123 return dp;
00124 }
00125
00126 inline point3d
00127 point3d::plus_dp(const dpoint3d& dp) const
00128 {
00129 point3d p = *this;
00130 p += dp;
00131 return p;
00132 }
00133
00134 inline point3d
00135 point3d::minus_dp(const dpoint3d& dp) const
00136 {
00137 point3d p = *this;
00138 p -= dp;
00139 return p;
00140 }
00141
00142 inline point3d
00143 point3d::minus() const
00144 {
00145 point3d p(-slice(), -row(), -col());
00146 return p;
00147 }
00148
00149 }
00150
00151
00152 inline std::ostream&
00153 operator<<(std::ostream& o, const oln::point3d& p)
00154 {
00155 return o << '(' << p.slice() << ',' << p.row() << ',' << p.col() << ')';
00156 }
00157
00158
00159
00160 #endif // ! OLENA_CORE_POINT3D_HXX