Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_coord.h
Go to the documentation of this file.
1 /*
2 Copyright 2010-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 #ifndef _VE_COORD_H_
17 #define _VE_COORD_H_
18 
19 #include <vector>
20 #include <string>
21 #include <iostream>
22 #include "a_coord_base.h"
23 #include "a_mat_c.h"
24 #include "a_point.h"
25 
32 class a_coord : public a_coord_base
33 {
34 public:
35  a_coord();
36  a_coord(const std::string& aname);
37  a_coord(const a_coord& coord);
38  ~a_coord();
39  virtual const std::string classname() {return "a_coord";};
40  static const std::string help();
41 
42  std::string name() const { return name_; };
43  void name(const std::string& name) { name_ = name; };
44 
45  void deg() {radian_ = false;}; //angles' unit to degree
46  void rad() {radian_ = true;}; // radian
47  void mode(const bool m) {radian_=m;}
48  double mode() const {return radian_;}
49 
50  void mat(a_mat_sq& r) const;
51  void mat(const a_mat_sq& r);
52  void R(a_mat_sq& r) const;
53  void R(const a_mat_sq& r);
54  void T(a_mat_c& t) const;
55  void T(const a_mat_c& t);
56 
57  void reset();
58  void translate(double, double, double);
59  void translate(const a_point& p) {this->translate(p.x(),p.y(),p.z());};
60  void translateW(double, double, double);
61  void translateW(const a_point& p) {this->translateW(p.x(),p.y(),p.z());};
62  void scale(double, double, double);
63  void scale(double); //uniform scaling
64  void rotateX(double); //rotate about the x local axis (in radian_ unit)
65  void rotateY(double); // y
66  void rotateZ(double); // z
67  void rotateXW(double); //rotate about the x world axis (in radian_ unit)
68  void rotateYW(double); // y
69  void rotateZW(double); // z
70  void orient(const a_mat_c& o, const a_mat_c& x, const a_mat_c& y);
71  void orient(const a_point& o, const a_point& x, const a_point& y);
72  /* o : position of the new origin
73  x : pt on the new x axis (x')
74  y : pt in the x'y' plane & in the direction of positive y'
75  ! all positions in world coordinate */
76  a_coord invert() const;
77  a_point w2l(const a_point& pt) const;
78  a_point l2w(const a_point& pt) const;
79 
80  //: input/output
81  virtual void read(std::istream &i);
82  virtual void write(std::ostream &o) const;
83 
84  static const double pi;
85 
86 protected:
87  std::string name_; //a reference name
88  bool radian_; //unit for the angles
89 };
90 
91 a_mat_c operator*(const a_coord& c, const a_mat_c& pt);
92 
93 #endif
a_mat_c operator*(const a_coord &c, const a_mat_c &pt)
Definition: a_coord.cxx:362
a coordinate system in the Points&Forces file format
Definition: a_coord.h:33
void reset()
Definition: a_coord.cxx:80
virtual const std::string classname()
Definition: a_coord.h:39
void mode(const bool m)
Definition: a_coord.h:47
static const double pi
Definition: a_coord.h:84
a_point l2w(const a_point &pt) const
convert coordinates from world to local
Definition: a_coord.cxx:347
void rotateYW(double)
Definition: a_coord.cxx:222
void mat(a_mat_sq &r) const
Definition: a_coord.cxx:85
void rotateXW(double)
Definition: a_coord.cxx:209
void rotateY(double)
Definition: a_coord.cxx:183
void T(a_mat_c &t) const
Definition: a_coord.cxx:125
void rotateX(double)
Definition: a_coord.cxx:170
void deg()
Definition: a_coord.h:45
void translateW(const a_point &p)
translate the coordinate system (translation in world coordinates)
Definition: a_coord.h:61
~a_coord()
Definition: a_coord.cxx:75
void rotateZW(double)
Definition: a_coord.cxx:235
double mode() const
Definition: a_coord.h:48
virtual void read(std::istream &i)
convert coordinates from local to world
Definition: a_coord.cxx:291
a_coord()
Definition: a_coord.cxx:61
std::string name_
Definition: a_coord.h:87
void name(const std::string &name)
Definition: a_coord.h:43
void translate(double, double, double)
reset to the world coordinate system
Definition: a_coord.cxx:141
std::string name() const
Definition: a_coord.h:42
void R(a_mat_sq &r) const
Definition: a_coord.cxx:107
a_point w2l(const a_point &pt) const
Definition: a_coord.cxx:334
void translateW(double, double, double)
Definition: a_coord.cxx:148
static const std::string help()
Definition: a_coord.cxx:26
void rotateZ(double)
Definition: a_coord.cxx:196
void scale(double, double, double)
Definition: a_coord.cxx:158
void translate(const a_point &p)
translate the coordinate system (translation in local coordinates)
Definition: a_coord.h:59
void rad()
Definition: a_coord.h:46
a_coord invert() const
Definition: a_coord.cxx:314
void orient(const a_mat_c &o, const a_mat_c &x, const a_mat_c &y)
Definition: a_coord.cxx:248
bool radian_
Definition: a_coord.h:88
virtual void write(std::ostream &o) const
Definition: a_coord.cxx:308
a column matrix unit
Definition: a_mat_c.h:29
a square matrix unit
Definition: a_mat_sq.h:29
std::valarray< double > & x() const
Definition: a_mat.h:53
double z() const
Definition: a_point.h:56
double y() const
Definition: a_point.h:55
double x() const
Definition: a_point.h:54