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

« back to all changes in this revision

Viewing changes to sphere_fitting/fit_3d_sphere.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 "fit_3d_sphere.h"
 
14
#include <cmath>
 
15
#include <iostream>
 
16
 
 
17
using std::sqrt;
 
18
 
 
19
fit_3d_sphere_fn::fit_3d_sphere_fn(const AGeometricObject* GO1,
 
20
                                   const AGeometricObject* GO2,
 
21
                                   const AGeometricObject* GO3,
 
22
                                   const AGeometricObject* GO4)
 
23
{
 
24
  m_GO1=GO1;
 
25
  m_GO2=GO2;
 
26
  m_GO3=GO3;
 
27
  m_GO4=GO4;
 
28
}
 
29
 
 
30
double fit_3d_sphere_fn::operator()(const nvector<double,3>& data) const
 
31
{
 
32
  Vector3 x=Vector3(data[0],data[1],data[2]);
 
33
 
 
34
  double ra=m_GO1->getDist(x);
 
35
  double rb=m_GO2->getDist(x);
 
36
  double rc=m_GO3->getDist(x);
 
37
  double rd=m_GO4->getDist(x);
 
38
 
 
39
  double rq=(ra+rb+rc+rd)*0.25;
 
40
  double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)+(rq-rd)*(rq-rd));
 
41
 
 
42
  return dr;
 
43
}