1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/**
\file polar_ellipse.hpp
\brief defing ellipse in polar coordinate
\author Junhua Gu
*/
#ifndef PELLIPSE_MODEL_H_
#define PELLIPSE_MODEL_H_
#define OPT_HEADER
#include <core/fitter.hpp>
#include <cmath>
namespace opt_utilities
{
template <typename T>
class polar_ellipse
:public model<T,T,std::vector<T>,std::string>
{
private:
model<T,T,std::vector<T> >* do_clone()const
{
return new polar_ellipse<T>(*this);
}
const char* do_get_type_name()const
{
return "ellipse in polar coordinate system";
}
public:
polar_ellipse()
{
this->push_param_info(param_info<std::vector<T> >("a",1,0,10));
this->push_param_info(param_info<std::vector<T> >("e",0,0,1));
this->push_param_info(param_info<std::vector<T> >("theta0",0,0,360));
}
public:
T do_eval(const T& x,const std::vector<T>& param)
{
double a=param[0];
double e=param[1];
double t0=param[2];
double t=x-t0;
t=t/180.*3.14159265358979;
return a*(1-e*e)/(1-e*cos(t));
}
private:
std::string do_get_information()const
{
return "polar elliptical\n";
//"y=k*x+b\n";
}
};
}
#endif
//EOF
|