SUMO - Simulation of Urban MObility
euler.h
Go to the documentation of this file.
1 /************************************************************************
2  * *
3  * Copyright 2004, Brown University, Providence, RI *
4  * *
5  * Permission to use and modify this software and its documentation *
6  * for any purpose other than its incorporation into a commercial *
7  * product is hereby granted without fee. Recipient agrees not to *
8  * re-distribute this software or any modifications of this *
9  * software without the permission of Brown University. Brown *
10  * University makes no representations or warrantees about the *
11  * suitability of this software for any purpose. It is provided *
12  * "as is" without express or implied warranty. Brown University *
13  * requests notification of any modifications to this software or *
14  * its documentation. Notice should be sent to: *
15  * *
16  * To: *
17  * Software Librarian *
18  * Laboratory for Engineering Man/Machine Systems, *
19  * Division of Engineering, Box D, *
20  * Brown University *
21  * Providence, RI 02912 *
22  * Software_Librarian@lems.brown.edu *
23  * *
24  * We will acknowledge all electronic notifications. *
25  * *
26  ************************************************************************/
27 
28 #ifndef EULER_H
29 #define EULER_H
30 
31 // Rewritten by Amir: Feb 1, 2004
32 
33 #include "angles.h"
34 #include "BiArc.h"
35 #include <vector>
36 
37 //some defines for Euler-spiral optimization
38 #define MAX_NUM_ITERATIONS 50000
39 #define eError 1e-5
40 
41 class EulerSpiralParams;
43 class EulerSpiral;
44 
46 {
47 public:
50 
51  double start_angle;
52  double end_angle;
53  double K0;
54  double K2;
55  double gamma;
56  double L;
57  double turningAngle;
58  double error;
59  double psi;
60 
62  {
63  start_angle = 0;
64  end_angle = 0;
65  K0 = 0;
66  K2 = 0;
67  gamma = 0;
68  L = 0;
69  turningAngle = 0;
70  error = 0;
71  psi = 0;
72  }
73 
75 
77  {
78  start_pt = rhs.start_pt;
79  end_pt = rhs.end_pt;
80  start_angle = rhs.start_angle;
81  end_angle = rhs.end_angle;
82  K0 = rhs.K0;
83  K2 = rhs.K2;
84  gamma = rhs.gamma;
85  L = rhs.L;
86  turningAngle = rhs.turningAngle;
87  error = rhs.error;
88  psi = rhs.psi;
89  }
90 
92  {
93  if (this!=&rhs)
94  {
95  start_pt = rhs.start_pt;
96  end_pt = rhs.end_pt;
97  start_angle = rhs.start_angle;
98  end_angle = rhs.end_angle;
99  K0 = rhs.K0;
100  K2 = rhs.K2;
101  gamma = rhs.gamma;
102  L = rhs.L;
103  turningAngle = rhs.turningAngle;
104  error = rhs.error;
105  psi = rhs.psi;
106  }
107  return *this;
108  }
109 };
110 
112 {
113 private:
114  // following line commented out to make clang compiler happy, MB 14.06.2014
115  //int NN; //size of the lookup tables (NNxNN) or number of data points between -pi and pi
116  double* _theta; //lookup the theta value corresponding to the index NN long
117  double _dt; //delta theta
118 
119  //lookup tables read in from files
120  double** ES_k0;
121  double** ES_k1;
122  double** ES_gamma;
123  double** ES_L;
124 
125 public:
128 
129  static EulerSpiralLookupTable* get_globalEulerSpiralLookupTable();
130 
131  double k0(double start_angle, double end_angle);
132  double k1(double start_angle, double end_angle);
133  double gamma(double start_angle, double end_angle);
134  double L(double start_angle, double end_angle);
135 
136  double dt(); //delta theta values for the table (tells you about the accuracy of the lookup)
137  double theta(int N); //lookup the theta value indexed by N
138 };
139 
141 {
142 private:
144 
145 public:
147  std::vector <Point2D<double> > pts;
148 
150 
151  //constructor Type 1
153  {
154  params.start_pt = start_pt;
155  params.start_angle = angle0To2Pi(start_angle);
156 
157  params.end_pt = end_pt;
158  params.end_angle = angle0To2Pi(end_angle);
159 
160  //since we have all the parameters, we might as well compute it
161  compute_es_params();
162  }
163 
164  //Constructor type 2
165  EulerSpiral(Point2D<double> start_pt, double start_angle, double k0, double gamma, double L)
166  {
167  params.start_pt = start_pt;
168  params.start_angle = angle0To2Pi(start_angle);
169  params.end_pt = compute_end_pt(k0, gamma, L);
170  params.end_angle = start_angle + 0.5*gamma*L*L + k0*L;
171 
172  //since we have all the parameters, we might as well compute it
173  compute_es_params();
174  }
175 
177  {
178  params.start_pt = start_pt;
179  params.start_angle = angle0To2Pi(start_angle);
180  }
181 
183  {
184  params.end_pt = end_pt;
185  params.end_angle = angle0To2Pi(end_angle);
186  }
187 
189  {
190  params.start_pt = start_pt;
191  params.start_angle = angle0To2Pi(start_angle);
192 
193  params.end_pt = end_pt;
194  params.end_angle = angle0To2Pi(end_angle);
195  }
196 
197  void compute_es_params ();
198 
199  //compute the extrinsic points
200  void computeSpiral(std::vector<Point2D<double> > &spiral, double ds=0, int NPts=0);
201 
202  // Supporting functions
203  Point2D<double> get_fresnel_integral(double value);
204  Point2D<double> compute_end_pt(double arclength, bool bNormalized=false);
205  Point2D<double> compute_end_pt(double k0, double gamma, double L, bool bNormalized=false);
206  Point2D<double> compute_es_point(EulerSpiralParams& es_params, double arclength, bool bNormalized=false);
207  inline double compute_error(double k0, double L);
208 
209  // function to output data
210 // void write_es_info_to_file(vcl_ofstream & fp);
211 };
212 
213 #endif
214 
EulerSpiralParams params
Definition: euler.h:146
EulerSpiralParams(const EulerSpiralParams &rhs)
Definition: euler.h:76
std::vector< Point2D< double > > pts
Definition: euler.h:147
double error
Definition: euler.h:58
void set_end_params(Point2D< double > end_pt, double end_angle)
Definition: euler.h:182
void set_params(Point2D< double > start_pt, double start_angle, Point2D< double > end_pt, double end_angle)
Definition: euler.h:188
Point2D< double > end_pt
Definition: euler.h:49
double start_angle
Definition: euler.h:51
double angle0To2Pi(double angle)
Definition: angles.h:40
EulerSpiral()
Definition: euler.h:149
double turningAngle
Definition: euler.h:57
double ** ES_gamma
Definition: euler.h:122
double K0
Definition: euler.h:53
double K2
Definition: euler.h:54
double ** ES_L
Definition: euler.h:123
double psi
Definition: euler.h:59
double ** ES_k0
Definition: euler.h:120
EulerSpiralParams & operator=(const EulerSpiralParams &rhs)
Definition: euler.h:91
double gamma
Definition: euler.h:55
double L
Definition: euler.h:56
BiArc _bi_arc_estimate
Definition: euler.h:143
double ** ES_k1
Definition: euler.h:121
EulerSpiral(Point2D< double > start_pt, double start_angle, double k0, double gamma, double L)
Definition: euler.h:165
EulerSpiralParams()
Definition: euler.h:61
void set_start_params(Point2D< double > start_pt, double start_angle)
Definition: euler.h:176
EulerSpiral(Point2D< double > start_pt, double start_angle, Point2D< double > end_pt, double end_angle)
Definition: euler.h:152
Definition: BiArc.h:165
double end_angle
Definition: euler.h:52
Point2D< double > start_pt
Definition: euler.h:48
~EulerSpiralParams()
Definition: euler.h:74