1
/////////////////////////////////////////////////////////////
3
// Copyright (c) 2007-2011 by The University of Queensland //
4
// Earth Systems Science Computational Centre (ESSCC) //
5
// http://www.uq.edu.au/esscc //
7
// Primary Business: Brisbane, Queensland, Australia //
8
// Licensed under the Open Software License version 3.0 //
9
// http://www.opensource.org/licenses/osl-3.0.php //
11
/////////////////////////////////////////////////////////////
13
#include "SphereSectionVol.h"
22
// --- STL includes ---
27
SphereSectionVol::SphereSectionVol()
30
SphereSectionVol::SphereSectionVol(const Vector3& c,const double r,const double h, const Vector3& n)
37
pair<Vector3,Vector3> SphereSectionVol::getBoundingBox()
39
Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),m_sph.Radius());
40
return make_pair(m_sph.Center()-r,m_sph.Center()+r);
43
Vector3 SphereSectionVol::getAPoint(int) const
45
double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX));
46
double phi=M_PI*((double)(rand())/(double)(RAND_MAX));
47
double rho=2*M_PI*((double)(rand())/(double)(RAND_MAX));
49
return m_sph.Center()+r*Vector3(sin(phi)*cos(rho),sin(phi)*sin(rho),cos(phi));
52
const map<double,const AGeometricObject*> SphereSectionVol::getClosestObjects(const Vector3& P,int) const
54
map<double,const AGeometricObject*> res;
56
res.insert(make_pair(m_sph.getDist(P),&m_sph));
61
bool SphereSectionVol::isIn(const Vector3& P) const
69
posn_vector = P - m_sph.Center();
70
dist = posn_vector.norm();
71
if (dist<m_sph.Radius()) {
72
norm_comp = dot(posn_vector,m_section_normal);
73
if ((norm_comp < 0)&&(fabs(norm_comp)>m_section_dist)) {
74
if ((fabs(norm_comp)/dist - m_section_dist/m_sph.Radius()) > 0) {
83
bool SphereSectionVol::isIn(const Sphere& S)
89
if ((isIn(S.Center()))&&(m_sph.getDist(S.Center())>S.Radius())) {
96
Check if sphere is fully outside the volume.
99
\warning DUMMY IMPLEMENTATION
101
bool SphereSectionVol::isFullyOutside(const Sphere& S)
106
ostream& operator << (ostream& ost,const SphereSectionVol& T)