Points&Forces (survey)
Software tools facilitating the task of surveying architecture
g_point.cxx
Go to the documentation of this file.
1 /*
2  Copyright 2002-2012 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 "g_point.h"
17 #include <math.h>
18 
19 const double pi = 3.14159265358979;
20 const double r2d = 180./pi;
21 const double r2g = 200./pi;
22 
23 //---------------------------------------------------------------------------
24 void g_point::print(std::ostream& o)
25 {
26  g_point a(*this);
27  a.normalise();
28  o << "direction vector : " << a << std::endl;
29  o << "distances" << std::endl;
30  o << "d " << this->norm() << std::endl;
31  o << "dx " << this->x() << std::endl;
32  o << "dy " << this->y() << std::endl;
33  o << "dz " << this->z() << std::endl;
34  o << "orientation" << std::endl;
35  o << "cx " << r2d*acos(a.x()) << " deg = " << r2g*acos(a.x()) << " gon " << std::endl;
36  o << "cy " << r2d*acos(a.y()) << " deg = " << r2g*acos(a.y()) << " gon " << std::endl;
37  o << "cz " << r2d*acos(a.z()) << " deg = " << r2g*acos(a.z()) << " gon" << std::endl;
38  g_point b(a.x(),a.y(),0.);
39  b.normalise();
40  if (b.y() < 0)
41  o << "azimuth " << 360.-r2d*acos(b.x()) << " deg = " << 400.-r2g*acos(b.x()) << " gon" << std::endl;
42  else
43  o << "azimuth " << r2d*acos(b.x()) << " deg = " << r2g*acos(b.x()) << " gon" << std::endl;
44  o << "elevation " << 90.-r2d*acos(a.z()) << " deg = " << 100.-r2g*acos(a.z()) << " gon" << std::endl;
45 }
46 //---------------------------------------------------------------------------
47 void g_point::print(a_text& o)
48 {
49  g_point a(*this);
50  a.normalise();
51  o << "direction vector : " << a << std::endl;
52  bool state0 = o.use_user_unit();
53  o << "distances" << std::endl;
54  o << "d " << this->norm() << std::endl;
55  o << "dx " << this->x() << std::endl;
56  o << "dy " << this->y() << std::endl;
57  o << "dz " << this->z() << std::endl;
58  o.use_user_unit(0);
59  o << "orientation" << std::endl;
60  o << "cx " << r2d*acos(a.x()) << " deg = " << r2g*acos(a.x()) << " gon " << std::endl;
61  o << "cy " << r2d*acos(a.y()) << " deg = " << r2g*acos(a.y()) << " gon " << std::endl;
62  o << "cz " << r2d*acos(a.z()) << " deg = " << r2g*acos(a.z()) << " gon" << std::endl;
63  g_point b(a.x(),a.y(),0);
64  b.normalise();
65  if (b.y() < 0)
66  o << "azimuth " << 360.-r2d*acos(b.x()) << " deg = " << 400.-r2g*acos(b.x()) << " gon" << std::endl;
67  else
68  o << "azimuth " << r2d*acos(b.x()) << " deg = " << r2g*acos(b.x()) << " gon" << std::endl;
69  o << "elevation " << 90.-r2d*acos(a.z()) << " deg = " << 100.-r2g*acos(a.z()) << " gon" << std::endl;
70  if (state0) o.use_user_unit(1);
71 }
a geometric point
Definition: g_point.h:30
void print(std::ostream &o)
Definition: g_point.cxx:24
const double pi
Definition: g_point.cxx:19
const double r2d
Definition: g_point.cxx:20
const double r2g
Definition: g_point.cxx:21