SUMO - Simulation of Urban MObility
BiArc.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 BI_ARC_H
29 #define BI_ARC_H
30 
31 #include "points.h"
32 #include "angles.h"
33 
34 #define eA 0.0001 //Epsilon for angles
35 #define eK 0.0001 //Epsilon for curvature
36 #define K_LARGE 100000 //large curvature value
37 
39 {
40 public:
41  int flag; //0:single arc, 1:biarc
42 
45 
46  double start_angle;
47  double end_angle;
48 
49  double K1;
50  double K2;
51 
52  double L1;
53  double L2;
54 
55  double E; //energy
56 
57  double R1;
58  double R2;
59 
60  int dir1;
61  int dir2;
62 
66 
68  {
69  flag = 0;
70 
71  start_angle = 0;
72  end_angle = 0;
73 
74  K1 = 0;
75  K2 = 0;
76 
77  L1 = 0;
78  L2 = 0;
79 
80  dir1 = 0;
81  dir2 = 0;
82 
83  R1 = 0;
84  R2 = 0;
85 
86  E = 0;
87 
88  };
89 
91 
92  BiArcParams( const BiArcParams &rhs)
93  {
94  start_pt = rhs.start_pt;
95  end_pt = rhs.end_pt;
96 
97  start_angle = rhs.start_angle;
98  end_angle = rhs.end_angle;
99 
100  K1 = rhs.K1;
101  K2 = rhs.K2;
102 
103  L1 = rhs.L1;
104  L2 = rhs.L2;
105 
106  mid_pt = rhs.mid_pt;
107  center1 = rhs.center1;
108  center2 = rhs.center2;
109 
110  dir1 = rhs.dir1;
111  dir2 = rhs.dir2;
112 
113  R1 = rhs.R1;
114  R2 = rhs.R2;
115 
116  flag = rhs.flag;
117  E = rhs.E;
118 
119  };
120 
122  {
123  if (this!=&rhs){
124  start_pt = rhs.start_pt;
125  end_pt = rhs.end_pt;
126 
127  start_angle = rhs.start_angle;
128  end_angle = rhs.end_angle;
129 
130  K1 = rhs.K1;
131  K2 = rhs.K2;
132 
133  L1 = rhs.L1;
134  L2 = rhs.L2;
135 
136  mid_pt = rhs.mid_pt;
137  center1 = rhs.center1;
138  center2 = rhs.center2;
139 
140  dir1 = rhs.dir1;
141  dir2 = rhs.dir2;
142 
143  R1 = rhs.R1;
144  R2 = rhs.R2;
145 
146  flag = rhs.flag;
147  E = rhs.E;
148  }
149  return *this;
150  }
151 
152  //total arclength
153  double L(){return (L1+L2);}
154 
155  void scale (double factor)
156  {
157  K1 /=factor;
158  L1 *=factor;
159 
160  K2 /=factor;
161  L2 *=factor;
162  }
163 };
164 
165 class BiArc
166 {
167 public:
169 
170  BiArc(){}
172  {
173  params.start_pt = start_pt;
174  params.start_angle = angle0To2Pi(start_angle);
175 
176  params.end_pt = end_pt;
177  params.end_angle = angle0To2Pi(end_angle);
178 
179  //since we have all the parameters, we might as well compute it
180  compute_biarc_params();
181  }
182 
183  ~BiArc(){}
184 
185  void compute_biarc_params ();
186  void compute_other_stuff ();
187  double compute_join_theta (double k1, double k2);
188  double compute_arclength (double theta0, double theta2, double k);
189 
191  {
192  params.start_pt = start_pt;
193  params.start_angle = angle0To2Pi(start_angle);
194  }
195 
197  {
198  params.end_pt = end_pt;
199  params.end_angle = angle0To2Pi(end_angle);
200  }
201 };
202 
203 #endif
double L()
Definition: BiArc.h:153
void scale(double factor)
Definition: BiArc.h:155
double K2
Definition: BiArc.h:50
~BiArcParams()
Definition: BiArc.h:90
void set_end_params(Point2D< double > end_pt, double end_angle)
Definition: BiArc.h:196
int flag
Definition: BiArc.h:41
void set_start_params(Point2D< double > start_pt, double start_angle)
Definition: BiArc.h:190
double E
Definition: BiArc.h:55
BiArc(Point2D< double > start_pt, double start_angle, Point2D< double > end_pt, double end_angle)
Definition: BiArc.h:171
Point2D< double > mid_pt
Definition: BiArc.h:63
double L1
Definition: BiArc.h:52
double angle0To2Pi(double angle)
Definition: angles.h:40
double start_angle
Definition: BiArc.h:46
Point2D< double > start_pt
Definition: BiArc.h:43
~BiArc()
Definition: BiArc.h:183
double L2
Definition: BiArc.h:53
double R1
Definition: BiArc.h:57
double K1
Definition: BiArc.h:49
BiArcParams()
Definition: BiArc.h:67
BiArcParams params
Definition: BiArc.h:168
BiArc()
Definition: BiArc.h:170
BiArcParams(const BiArcParams &rhs)
Definition: BiArc.h:92
Point2D< double > end_pt
Definition: BiArc.h:44
double R2
Definition: BiArc.h:58
double end_angle
Definition: BiArc.h:47
int dir2
Definition: BiArc.h:61
BiArcParams & operator=(const BiArcParams &rhs)
Definition: BiArc.h:121
Definition: BiArc.h:165
Point2D< double > center1
Definition: BiArc.h:64
int dir1
Definition: BiArc.h:60
Point2D< double > center2
Definition: BiArc.h:65