Points&Forces (survey)
Software tools facilitating the task of surveying architecture
a_plucker.cxx
Go to the documentation of this file.
1 /*
2 Copyright 2010-2011 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 
17 //#include <math.h> // math routines
18 #include "a_plucker.h"
19 
20 //---------------------------------------------------------------------------
22 : p1_(0.,0.,0.), p2_(0.,0.,0.)
23 {}
24 
25 //---------------------------------------------------------------------------
26 a_plucker::a_plucker(double ax, double ay, double az, double bx, double by, double bz)
27 : p1_(ax,ay,az), p2_(bx,by,bz)
28 {
29 }
30 //---------------------------------------------------------------------------
32 : p1_(f.p1_), p2_(f.p2_)
33 {}
34 //---------------------------------------------------------------------------
36 {
37  p1_ = f.p1();
38  p2_ = f.p2();
39  return *this;
40 }
41 //---------------------------------------------------------------------------
43 {
44  p1_.operator-();
45  p2_.operator-();
46  return *this;
47 }
48 //---------------------------------------------------------------------------
50 {
51  a_plucker b2 = *this;
52  return b2 += b;
53 }
54 //---------------------------------------------------------------------------
56 {
57  a_plucker b2 = *this;
58  return b2 -= b;
59 }
60 //---------------------------------------------------------------------------
62 {
63  p1_ += b.p1_;
64  p2_ += b.p2_;
65  return *this;
66 }
67 //---------------------------------------------------------------------------
69 {
70  p1_ -= b.p1_;
71  p2_ -= b.p2_;
72  return *this;
73 }
74 //---------------------------------------------------------------------------
76 {
77  p1_ *= b;
78  p2_ *= b;
79  return *this;
80 }
81 //---------------------------------------------------------------------------
83 {
84  p1_ /= b;
85  p2_ /= b;
86  return *this;
87 }
88 //---------------------------------------------------------------------------
89 bool a_plucker::operator==(const a_plucker& a) const
90 {
91  return (a.p1_ == this->p1_ && a.p2_ == this->p2_);
92 }
93 //---------------------------------------------------------------------------
94 bool a_plucker::operator!=(const a_plucker& a) const
95 {
96  return !(*this==a);
97 }
98 //---------------------------------------------------------------------------
99 void a_plucker::read(std::istream &in)
100 {
101  in >> p1_;
102  in >> p2_;
103 }
104 //---------------------------------------------------------------------------
105 void a_plucker::write(std::ostream &o) const
106 {
107  o << p1_ << " " << p2_;
108 }
109 //***************************************************************************
110 //---------------------------------------------------------------------------
111 std::istream& operator>> (std::istream& i, a_plucker& f)
112 {
113  f.read(i);
114  return i;
115 }
116 //---------------------------------------------------------------------------
117 std::ostream& operator<<(std::ostream& o, const a_plucker& f)
118 {
119  f.write(o);
120  return o;
121 }
122 //---------------------------------------------------------------------------
123 std::istream& operator>> (std::istream& i, a_plucker* f)
124 {
125  f->read(i);
126  return i;
127 }
128 //---------------------------------------------------------------------------
129 std::ostream& operator<<(std::ostream& o, const a_plucker* f)
130 {
131  f->write(o);
132  return o;
133 }
134 //***************************************************************************
135 //---------------------------------------------------------------------------
136 double operator*(const a_plucker & a, const a_plucker & b)
137 {
138  return a.p1()*b.p2()+a.p2()*b.p1();
139 }
140 
std::istream & operator>>(std::istream &i, a_plucker &f)
Definition: a_plucker.cxx:111
std::ostream & operator<<(std::ostream &o, const a_plucker &f)
Definition: a_plucker.cxx:117
double operator*(const a_plucker &a, const a_plucker &b)
Definition: a_plucker.cxx:136
a plucker class
Definition: a_plucker.h:31
a_point p1_
Definition: a_plucker.h:63
a_plucker & operator=(const a_plucker &m)
Definition: a_plucker.cxx:35
a_plucker & operator*=(double v)
Definition: a_plucker.cxx:75
a_point p2_
Definition: a_plucker.h:64
bool operator!=(const a_plucker &a) const
Definition: a_plucker.cxx:94
a_plucker & operator/=(double v)
Definition: a_plucker.cxx:82
a_plucker & operator-()
Definition: a_plucker.cxx:42
virtual a_plucker operator+(const a_plucker &a)
Definition: a_plucker.cxx:49
bool operator==(const a_plucker &a)
virtual void write(std::ostream &o) const
Definition: a_plucker.cxx:105
a_point p2() const
Definition: a_plucker.h:42
a_point p1() const
Definition: a_plucker.h:41
virtual void read(std::istream &i)
Definition: a_plucker.cxx:99
a_plucker & operator-=(const a_plucker &a)
Definition: a_plucker.cxx:68
a_plucker & operator+=(const a_plucker &a)
Definition: a_plucker.cxx:61