Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_3dh.cxx
Go to the documentation of this file.
1 /*
2 Copyright 2019 Pierre SMARS (smars@yuntech.edu.tw)
3 This program is free software: you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation, either version 2 of the License, or
6 (at your option) any later version.
7 
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 
13 You should have received a copy of the GNU General Public License
14 along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16 #include "a_3dh.h"
17 #include <sstream>
18 //---------------------------------------------------------------------------
19 const std::string a_3dh::help()
20 {
21  std::ostringstream o;
22  o << "*****" << std::endl;
23  o << "a_3dh" << std::endl;
24  o << "****" << std::endl;
25  o << "This is a 3 dimensional homogeneous point class" << std::endl;
26  o << "Commands:" << std::endl;
27  o << "--------" << std::endl;
28  o << "X: set or get the homogeneous coordinate" << std::endl;
29  o << "Y: set or get the homogeneous coordinate" << std::endl;
30  o << "Z: set or get the homogeneous coordinate" << std::endl;
31  o << "T: set or get the homogeneous coordinate" << std::endl;
32  o << "x: get the coordinate (no check)" << std::endl;
33  o << "y: get the coordinate (no check)" << std::endl;
34  o << "z: get the coordinate (no check)" << std::endl;
35  o << "set x y z (t): set the coordinates" << std::endl;
36  o << "set a_point: set the coordinates" << std::endl;
37  o << "point: get a_point representation (no check)" << std::endl;
38  return o.str();
39 }
40 //---------------------------------------------------------------------------
41 a_3dh::a_3dh(const a_mat& m) : a_mat_c(4)
42 {
43  if (m.maxi() != maxi_) throw compatibility_error();
44  if (m.maxj() != maxj_) throw compatibility_error();
45  for (int i = 0; i<4; i++)
46  (*this)(i)= m(i,0);
47 }
48 //***************************************************************************
49 //-operator>>----------------------------------------------------------------
50 std::istream& operator>> (std::istream& i, a_3dh & m)
51 {
52  double x,y,z;
53  i >> x >> y >> z;
54  m.X(x);
55  m.Y(y);
56  m.Z(z);
57  m.T(1.);
58  return i;
59 }
60 //-operator<<----------------------------------------------------------------
61 std::ostream& operator<< (std::ostream& o, const a_3dh & m)
62 {
63  o << m.x() << " " << m.y() << " " << m.z() << std::endl;
64  return o;
65 }
std::ostream & operator<<(std::ostream &o, const a_3dh &m)
Definition: a_3dh.cxx:61
std::istream & operator>>(std::istream &i, a_3dh &m)
Definition: a_3dh.cxx:50
an homogeneous 3d matrix class
Definition: a_3dh.h:30
a_3dh()
Definition: a_3dh.h:32
double y() const
Definition: a_3dh.h:51
void T(double v)
Definition: a_3dh.h:45
double x() const
Definition: a_3dh.h:50
double z() const
Definition: a_3dh.h:52
void X(double v)
Definition: a_3dh.h:42
void Z(double v)
Definition: a_3dh.h:44
static const std::string help()
Definition: a_3dh.cxx:19
void Y(double v)
Definition: a_3dh.h:43
a column matrix unit
Definition: a_mat_c.h:29
Definition: a_mat.h:42
UI maxj_
Definition: a_mat.h:89
UI maxi_
Definition: a_mat.h:88
UI maxi() const
Definition: a_mat.h:49
UI maxj() const
Definition: a_mat.h:50