File: CircleVol.cc

package info (click to toggle)
python-demgengeo 1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,004 kB
  • ctags: 2,158
  • sloc: cpp: 12,532; python: 1,260; makefile: 281; sh: 92
file content (87 lines) | stat: -rw-r--r-- 2,133 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2007-2014 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.opensource.org/licenses/osl-3.0.php          //
//                                                         //
/////////////////////////////////////////////////////////////

#include "CircleVol.h"

//--- 
#include <cmath>
#include <cstdlib>

using std::cos;
using std::sin; 

// --- STL includes ---
#include <utility>

using std::make_pair;

CircleVol::CircleVol()
{}

CircleVol::CircleVol(const Vector3& c,double r)
{
  m_sph=SphereIn(c,r);
}

pair<Vector3,Vector3> CircleVol::getBoundingBox()
{
  Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),0.0);
  return make_pair(m_sph.Center()-r,m_sph.Center()+r);
}

Vector3 CircleVol::getAPoint(int) const
{
  double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX));
  double rho=2.0*M_PI*((double)(rand())/(double)(RAND_MAX));

  return m_sph.Center()+r*Vector3(cos(rho),sin(rho),0.0);
}

Line2D CircleVol::getClosestPlane(const Vector3& V)
{
  Line2D res;

  return res;
}

const map<double, const Line2D*> CircleVol::getClosestPlanes(const Vector3& p,int nmax) const
{
  map<double,const Line2D*> res;

  return res;
}

const map<double,const AGeometricObject*> CircleVol::getClosestObjects(const Vector3& P,int) const
{
  map<double,const AGeometricObject*> res;

  res.insert(make_pair(m_sph.getDist(P),&m_sph));

  return res;  
}

bool CircleVol::isIn(const Vector3& P) const
{
  double dist=(m_sph.Center()-P).norm();
  return (dist<m_sph.Radius()); 
}

bool CircleVol::isIn(const Sphere& S)
{
  double dist=(m_sph.Center()-S.Center()).norm();
  return (dist+S.Radius()<m_sph.Radius()); 
}

ostream& operator << (ostream& ost,const CircleVol& T)
{
   return ost;
}