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

« back to all changes in this revision

Viewing changes to sphere_fitting/fit_functions/fit_2d_sphere_2lines.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_2lines.h"
 
14
#include <cmath>
 
15
 
 
16
using std::sqrt;
 
17
using std::fabs;
 
18
 
 
19
fit_2d_sphere_2lines_fn::fit_2d_sphere_2lines_fn(const Vector3& sc, double r,const Vector3& o1, const Vector3& n1,const Vector3& o2, const Vector3&n2)
 
20
{
 
21
  m_p=sc;
 
22
  m_r=r;
 
23
  m_orig1=o1;
 
24
  m_nor1=n1;
 
25
  m_orig2=o2;
 
26
  m_nor2=n2;
 
27
}
 
28
 
 
29
double fit_2d_sphere_2lines_fn::operator()(const nvector<double,2>& data) const
 
30
{
 
31
  double x=data[0];
 
32
  double y=data[1];
 
33
  double ra=sqrt((x-m_p.x())*(x-m_p.x())+(y-m_p.y())*(y-m_p.y()))-m_r;
 
34
  double rb=fabs(dot((Vector3(x,y,0.0)-m_orig1),m_nor1));
 
35
  double rc=fabs(dot((Vector3(x,y,0.0)-m_orig2),m_nor2));
 
36
  double rq=(ra+rb+rc)/3.0;
 
37
  double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc));
 
38
 
 
39
  return dr;
 
40
}