~ubuntu-branches/ubuntu/saucy/python-demgengeo/saucy

« back to all changes in this revision

Viewing changes to src/EllipsoidVol.cc

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2011-11-18 21:47:18 UTC
  • Revision ID: package-import@ubuntu.com-20111118214718-4ysqm3dhpqwdd7gd
Tags: upstream-0.99~bzr106
ImportĀ upstreamĀ versionĀ 0.99~bzr106

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/////////////////////////////////////////////////////////////
 
2
//                                                         //
 
3
// Copyright (c) 2007-2011 by The University of Queensland //
 
4
// Earth Systems Science Computational Centre (ESSCC)      //
 
5
// http://www.uq.edu.au/esscc                              //
 
6
//                                                         //
 
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          //
 
10
//                                                         //
 
11
/////////////////////////////////////////////////////////////
 
12
 
 
13
#include "EllipsoidVol.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
EllipsoidVol::EllipsoidVol()
 
28
{}
 
29
 
 
30
EllipsoidVol::EllipsoidVol(const Vector3& c, double lx, double ly, double lz)
 
31
{
 
32
  m_posn=c;
 
33
  m_lx=lx;
 
34
  m_ly=ly;
 
35
  m_lz=lz;
 
36
}
 
37
 
 
38
pair<Vector3,Vector3> EllipsoidVol::getBoundingBox()
 
39
{
 
40
  Vector3 r=Vector3(0.5*m_lx,0.5*m_ly,0.5*m_lz);
 
41
  return make_pair(m_posn-r,m_posn+r);
 
42
}
 
43
 
 
44
Vector3 EllipsoidVol::getAPoint(int) const
 
45
{
 
46
/*
 
47
  double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX));
 
48
  double phi=M_PI*((double)(rand())/(double)(RAND_MAX));
 
49
  double rho=2*M_PI*((double)(rand())/(double)(RAND_MAX));
 
50
*/
 
51
  double rx = m_lx*((double)(rand())/(double)(RAND_MAX) - 0.5);
 
52
  double ry = m_ly*((double)(rand())/(double)(RAND_MAX) - 0.5);
 
53
  double rz = m_lz*((double)(rand())/(double)(RAND_MAX) - 0.5);
 
54
 
 
55
  return m_posn + Vector3(rx,ry,rz);
 
56
}
 
57
 
 
58
const map<double,const AGeometricObject*> EllipsoidVol::getClosestObjects(const Vector3& P,int) const
 
59
{
 
60
  map<double,const AGeometricObject*> res;
 
61
 
 
62
//  res.insert(make_pair(m_sph.getDist(P),&m_sph));
 
63
 
 
64
  return res;  
 
65
}
 
66
 
 
67
bool EllipsoidVol::isIn(const Vector3& P) const
 
68
{
 
69
  Vector3 dR = P - m_posn;
 
70
  double rx = dR.x();
 
71
  double ry = dR.y();
 
72
  double rz = dR.z();
 
73
  double delta = rx*rx/(m_lx*m_lx) + ry*ry/(m_ly*m_ly) + rz*rz/(m_lz*m_lz) ;
 
74
  return (delta < 1.0);
 
75
}
 
76
 
 
77
/*!
 
78
  \warning WRONG
 
79
*/
 
80
bool EllipsoidVol::isIn(const Sphere& S)
 
81
{
 
82
//  return (m_sph.getDist(S.Center())>S.Radius()); 
 
83
  return (isIn(S.Center()));
 
84
}
 
85
 
 
86
/*
 
87
  Check if sphere is fully outside the volume.
 
88
 
 
89
  \param S the sphere
 
90
  \warning DUMMY IMPLEMENTATION
 
91
*/
 
92
bool EllipsoidVol::isFullyOutside(const Sphere&)
 
93
{
 
94
  return true;
 
95
}
 
96
 
 
97
ostream& operator << (ostream& ost,const EllipsoidVol& T)
 
98
{
 
99
   return ost;
 
100
}