Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_tetrahedron.h
Go to the documentation of this file.
1 /*
2 Copyright 2016 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_TETRAHEDRON_H_
17 #define _A_TETRAHEDRON_H_
18 
19 #include <iostream>
20 #include <stdlib.h>
21 #include "a_point.h"
22 #include "a_segment.h"
23 #include "a_triangle.h"
24 
31 {
32 public:
33  a_tetrahedron(const a_point& p1, const a_point& p2, const a_point& p3, const a_point& p4) {p_[0]=p1;p_[1]=p2;p_[2]=p3;p_[3]=p4;}
34  a_tetrahedron(const a_tetrahedron& p) {for (unsigned short i=0; i<4; i++) p_[i] = p.p_[i];}
35 
36  virtual const std::string classname() {return "a_tetrahedron";}
37  static const std::string help();
38  //: get points
39  inline a_point p1() const { return p_[0]; }
40  inline a_point p2() const { return p_[1]; }
41  inline a_point p3() const { return p_[2]; }
42  inline a_point p4() const { return p_[3]; }
43  inline a_point operator[](const int i) const {return p_[i%4];}
44  inline a_point p(const int ref) const {return p_[ref%4];}
45 
46  //: set points
47  inline void p1(const a_point& v) { p_[0] = v; }
48  inline void p2(const a_point& v) { p_[1] = v; }
49  inline void p3(const a_point& v) { p_[2] = v; }
50  inline void p4(const a_point& v) { p_[3] = v; }
51  inline void set(const a_point& p1, const a_point& p2, const a_point& p3, const a_point& p4) {p_[0] = p1; p_[1] = p2; p_[2] = p3; p_[3] = p4;}
52 
54  a_segment s(const int ref) const;
55  a_triangle f(const int ref) const;
57  inline a_point c() const {return (p_[0]+p_[1]+p_[2]+p_[3])/4.; }
58  a_tetrahedron& translate(double x, double y, double z);
59  a_tetrahedron& rotate(const a_point& x_axis, const a_point& y_axis, const a_point& z_axis);
61  double V() const;
63  double S() const;
65  bool contains(const a_point& p) const;
67  double quality() const;
68  bool operator==(const a_tetrahedron& p);
70 
71  //: input/output
72  virtual void read(std::istream &i);
73  virtual void write(std::ostream &o) const;
74 
75 protected:
76  a_point p_[4];
77 };
78 
79 #endif
a segment
Definition: a_segment.h:29
a tetrahedron
Definition: a_tetrahedron.h:31
static const std::string help()
a_point c() const
get centre of gravity
Definition: a_tetrahedron.h:57
a_point p_[4]
Definition: a_tetrahedron.h:76
virtual void read(std::istream &i)
bool contains(const a_point &p) const
check whether point lies inside triangle
a_point p2() const
Definition: a_tetrahedron.h:40
a_point p1() const
Definition: a_tetrahedron.h:39
a_point p(const int ref) const
Definition: a_tetrahedron.h:44
a_point operator[](const int i) const
Definition: a_tetrahedron.h:43
a_segment s(const int ref) const
get segment i (0-3) of tetrahedron
virtual void write(std::ostream &o) const
a_tetrahedron & rotate(const a_point &x_axis, const a_point &y_axis, const a_point &z_axis)
bool operator==(const a_tetrahedron &p)
void set(const a_point &p1, const a_point &p2, const a_point &p3, const a_point &p4)
Definition: a_tetrahedron.h:51
a_point p4() const
Definition: a_tetrahedron.h:42
a_tetrahedron(const a_tetrahedron &p)
Definition: a_tetrahedron.h:34
a_tetrahedron(const a_point &p1, const a_point &p2, const a_point &p3, const a_point &p4)
Definition: a_tetrahedron.h:33
void p2(const a_point &v)
Definition: a_tetrahedron.h:48
void p1(const a_point &v)
Definition: a_tetrahedron.h:47
virtual const std::string classname()
Definition: a_tetrahedron.h:36
a_point p3() const
Definition: a_tetrahedron.h:41
a_triangle f(const int ref) const
double quality() const
quality: ratio between smaller and bigger segment
double S() const
get surface
void p3(const a_point &v)
Definition: a_tetrahedron.h:49
a_tetrahedron & operator=(const a_tetrahedron &p)
double V() const
get volume
a_tetrahedron & translate(double x, double y, double z)
void p4(const a_point &v)
Definition: a_tetrahedron.h:50
a triangle
Definition: a_triangle.h:31