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

« back to all changes in this revision

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