Debian Codegraph @

src/CircleVol.cc

raw
1 ////////////////////////////////////////////////////////////
2 // //
3 // Copyright (c) 2007-2017 by The University of Queensland //
4 // Centre for Geoscience Computing //
5 // http://earth.uq.edu.au/centre-geoscience-computing //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.apache.org/licenses/LICENSE-2.0 //
10 // //
11 /////////////////////////////////////////////////////////////
12
13 #include "CircleVol.h"
14
15 //---
16 #include <cmath>
17 #include <cstdlib>
18
19 using std::cos;
20 using std::sin;
21
22 // --- STL includes ---
23 #include <utility>
24
25 using std::make_pair;
26
27 CircleVol::CircleVol()
28 {}
29
30 CircleVol::CircleVol(const Vector3& c,double r)
31 {
32 m_sph=SphereIn(c,r);
33 }
34
35 pair<Vector3,Vector3> CircleVol::getBoundingBox()
36 {
37 Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),0.0);
38 return make_pair(m_sph.Center()-r,m_sph.Center()+r);
39 }
40
41 Vector3 CircleVol::getAPoint(int) const
42 {
43 double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX));
44 double rho=2.0*M_PI*((double)(rand())/(double)(RAND_MAX));
45
46 return m_sph.Center()+r*Vector3(cos(rho),sin(rho),0.0);
47 }
48
49 Line2D CircleVol::getClosestPlane(const Vector3& V)
50 {
51 Line2D res;
52
53 return res;
54 }
55
56 const map<double, const Line2D*> CircleVol::getClosestPlanes(const Vector3& p,int nmax) const
57 {
58 map<double,const Line2D*> res;
59
60 return res;
61 }
62
63 const map<double,const AGeometricObject*> CircleVol::getClosestObjects(const Vector3& P,int) const
64 {
65 map<double,const AGeometricObject*> res;
66
67 res.insert(make_pair(m_sph.getDist(P),&m_sph));
68
69 return res;
70 }
71
72 bool CircleVol::isIn(const Vector3& P) const
73 {
74 double dist=(m_sph.Center()-P).norm();
75 return (dist<m_sph.Radius());
76 }
77
78 bool CircleVol::isIn(const Sphere& S)
79 {
80 double dist=(m_sph.Center()-S.Center()).norm();
81 return (dist+S.Radius()<m_sph.Radius());
82 }
83
84 ostream& operator << (ostream& ost,const CircleVol& T)
85 {
86 return ost;
87 }