Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_circle.h
Go to the documentation of this file.
1 /*
2 Copyright 2009-12 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_CIRCLE_H_
17 #define _A_CIRCLE_H_
18 
19 #include <iostream>
20 #include "a_point.h"
21 
29 const double pi = 3.14159265358979;
30 
31 class a_circle: public a_geom_base
32 {
33 public:
34  a_circle() = default;
35 
36  virtual const std::string classname() { return "a_segment";}
37  static const std::string help();
38 
39  void centre(const a_point c) {c_=c;}
40  a_point centre() const {return c_;}
41 
42  void normal(const a_point n) {n_=n; n_.normalise();}
43  a_point normal() const {return n_;}
44 
45  void radius(double r) {r_=r;}
46  double radius() const {return r_;}
47 
48  void p3(const a_point p1, const a_point p2, const a_point p3);
49  void p2(const a_point p1, const a_point p2); //use r_ and n_, order of points matters!
50 
51  bool operator==(const a_circle& p);
52  a_circle& operator=(const a_circle& v);
53 
54  inline double length() const { return 2*pi*r_;}
55  inline double area() const { return pi*r_*r_;}
56 
57  //: input/output
58  virtual void read(std::istream &i);
59  virtual void write(std::ostream &o) const;
60 
63 
64 protected:
65  a_point c_; // centre
66  a_point n_ = a_point(1.,0.,0.); // normal to the circle plane
67  double r_ = 0.; // radius
68 };
69 
70 #endif
const double pi
a circle
Definition: a_circle.h:29
a_circle & operator=(const a_circle &v)
Definition: a_circle.cxx:52
a_point normal() const
Definition: a_circle.h:43
static const std::string help()
Definition: a_circle.cxx:23
double radius() const
Definition: a_circle.h:46
a_point centre() const
Definition: a_circle.h:40
void p3(const a_point p1, const a_point p2, const a_point p3)
Definition: a_circle.cxx:60
a_point c_
Definition: a_circle.h:65
a_circle()=default
bool operator==(const a_circle &p)
Definition: a_circle.cxx:47
void p2(const a_point p1, const a_point p2)
Definition: a_circle.cxx:72
double length() const
Definition: a_circle.h:54
void normal(const a_point n)
Definition: a_circle.h:42
a_point n_
Definition: a_circle.h:66
double r_
Definition: a_circle.h:67
void centre(const a_point c)
Definition: a_circle.h:39
double area() const
Definition: a_circle.h:55
void radius(double r)
Definition: a_circle.h:45
virtual void read(std::istream &i)
Definition: a_circle.cxx:85
virtual const std::string classname()
Definition: a_circle.h:36
virtual void write(std::ostream &o) const
Definition: a_circle.cxx:92
a_point & normalise()
Definition: a_point.cxx:190