~ubuntu-branches/ubuntu/quantal/python-demgengeo/quantal

« back to all changes in this revision

Viewing changes to sphere_fitting/fit_functions/fit_2d_sphere_line.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_line.h"
 
14
#include <cmath>
 
15
 
 
16
using std::sqrt;
 
17
using std::fabs;
 
18
 
 
19
/*!
 
20
 */
 
21
fit_2d_sphere_line_fn::fit_2d_sphere_line_fn(const Vector3& sc1, double r1,const Vector3& sc2, double r2,const Vector3& o, const Vector3& n)
 
22
{
 
23
  m_p1=sc1;
 
24
  m_p2=sc2;
 
25
  m_r1=r1;
 
26
  m_r2=r2;
 
27
  m_orig=o;
 
28
  m_nor=n;
 
29
}
 
30
 
 
31
/*!
 
32
 */
 
33
double fit_2d_sphere_line_fn::operator()(const nvector<double,2>& data) const
 
34
{
 
35
  double x=data[0];
 
36
  double y=data[1];
 
37
  double ra=sqrt((x-m_p1.x())*(x-m_p1.x())+(y-m_p1.y())*(y-m_p1.y()))-m_r1;
 
38
  double rb=sqrt((x-m_p2.x())*(x-m_p2.x())+(y-m_p2.y())*(y-m_p2.y()))-m_r2;
 
39
  double rc=fabs(dot((Vector3(x,y,0.0)-m_orig),m_nor));
 
40
  double rq=(ra+rb+rc)/3.0;
 
41
  double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc));
 
42
 
 
43
  return dr;
 
44
}