Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_segment.h
Go to the documentation of this file.
1 /*
2  Copyright 2010-2017 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 _A_SEGMENT_H_
17 #define _A_SEGMENT_H_
18 
19 #include <iostream>
20 #include "a_point.h"
21 #include "a_mat_sq.h"
22 
28 class a_segment: public a_geom_base
29 {
30  public:
31  a_segment() : p1_(), p2_() {};
32  a_segment(const a_point p1, const a_point p2) : p1_(p1), p2_(p2) {}
33  a_segment(const a_segment& s) {p1_ = s.p1_; p2_ = s.p2_;}
34 
35  virtual const std::string classname() { return "a_segment";}
36  static const std::string help();
38  inline a_point p1() const { return p1_; }
40  inline a_point p2() const { return p2_; }
42  inline a_point vec() const {return (p2_-p1_);}
44  inline a_point dir() const {return (p2_-p1_).normalise();}
46  inline a_point c() const {return (p1_+p2_)/2.;}
48  inline void p1(const a_point v) { p1_ = v; }
50  inline void p2(const a_point v) { p2_ = v; }
51  inline a_segment& translate(double x, double y, double z) {p1_.translate(x,y,z); p2_.translate(x,y,z); return *this;}
52  a_segment& rotate(const a_point& x_axis, const a_point& y_axis, const a_point& z_axis);
53 
54  bool operator==(const a_segment& p);
55  a_segment& operator=(const a_segment& v);
56 
57  inline double length() const { return (p2_-p1_).norm();}
59  a_mat_sq inertia() const;
60  double project(const a_point v) const;
62  a_point closestl(const a_point& p) const;
64  a_point closest(const a_point& p) const;
66  double distl(const a_point& p) const;
68  double dist(const a_point& p) const;
72  a_segment intersect(const a_segment& s, double& m1, double& m2) const;
76  a_segment shortest(const a_segment& s, double& m1, double& m2) const;
78  double distl(const a_segment& s) const;
80  double dist(const a_segment& s) const;
81 
82  //: input/output
83  virtual void read(std::istream &i);
84  virtual void write(std::ostream &o) const;
85 
89  class denomin_error {};
90 
91 
92  protected:
95 };
96 
97 #endif
a square matrix unit
Definition: a_mat_sq.h:29
a_point & normalise()
Definition: a_point.cxx:190
a_point & translate(double x, double y, double z)
Definition: a_point.h:70
a segment
Definition: a_segment.h:29
bool operator==(const a_segment &p)
Definition: a_segment.cxx:69
double dist(const a_point &p) const
distance betweeen p and segment
Definition: a_segment.cxx:134
static const std::string help()
Definition: a_segment.cxx:25
a_point dir() const
get direction defined by segment
Definition: a_segment.h:44
a_segment()
Definition: a_segment.h:31
a_point vec() const
get vector between the two apices
Definition: a_segment.h:42
virtual const std::string classname()
Definition: a_segment.h:35
a_segment shortest(const a_segment &s, double &m1, double &m2) const
intersection between two segments, returns a segment between the closest point between the two segmen...
Definition: a_segment.cxx:177
a_segment & rotate(const a_point &x_axis, const a_point &y_axis, const a_point &z_axis)
Definition: a_segment.cxx:62
a_segment(const a_point p1, const a_point p2)
Definition: a_segment.h:32
double project(const a_point v) const
Definition: a_segment.cxx:103
a_segment(const a_segment &s)
Definition: a_segment.h:33
void p1(const a_point v)
set first apex of segment
Definition: a_segment.h:48
a_point p2_
Definition: a_segment.h:94
a_point c() const
center of segment
Definition: a_segment.h:46
double length() const
Definition: a_segment.h:57
a_segment & translate(double x, double y, double z)
Definition: a_segment.h:51
virtual void read(std::istream &i)
Definition: a_segment.cxx:378
a_mat_sq inertia() const
inertia of the segment
Definition: a_segment.cxx:81
a_segment intersect(const a_segment &s, double &m1, double &m2) const
intersection between two segments, returns a segment between the closest point between the two lines ...
Definition: a_segment.cxx:139
a_point closestl(const a_point &p) const
point closest to p on line defined by segment
Definition: a_segment.cxx:110
a_point p2() const
get second apex of segment
Definition: a_segment.h:40
a_point closest(const a_point &p) const
point closest to p inside segment
Definition: a_segment.cxx:117
double distl(const a_point &p) const
distance between p and line defined by segment
Definition: a_segment.cxx:129
a_point p1_
Definition: a_segment.h:93
a_segment & operator=(const a_segment &v)
Definition: a_segment.cxx:74
virtual void write(std::ostream &o) const
Definition: a_segment.cxx:384
void p2(const a_point v)
set second apex of segment
Definition: a_segment.h:50
a_point p1() const
get first apex of segment
Definition: a_segment.h:38