Skip to content

Commit 736ed17

Browse files
committed
Convert integer literal to a bool literal
1 parent 4ba9731 commit 736ed17

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

src/PathPlanning/Mapping.cpp

+45-45
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ boolean Is_Adjacent(t_vertexID id1, t_vertexID id2)
9696
{
9797
if ((vertex[id1].adjacency_active & ((t_adjacency)1u << id2))
9898
|| (vertex[id2].adjacency_active & ((t_adjacency)1u << id1)))
99-
return 1;
99+
return true;
100100

101-
return 0;
101+
return false;
102102
}
103103

104104
/****************************************************************************************
@@ -118,10 +118,10 @@ boolean Is_Intersection_Segment(Segment *s1, Segment *s2)
118118

119119
if ((s1->a == s2->a) && (s1->b == s2->b)) // segments are one the same line (parallel but not distinct)
120120
if (Is_Point_On_Segment(&s2->p1, s1) && Is_Point_On_Segment(&s2->p2, s1))
121-
return 1;
121+
return true;
122122

123123
if ((s1->a == s2->a) && (s1->b != s2->b)) // segments are parallel and distinct
124-
return 0;
124+
return false;
125125

126126
if (s1->a == 9999) // segment 1 is vertical
127127
{
@@ -140,9 +140,9 @@ boolean Is_Intersection_Segment(Segment *s1, Segment *s2)
140140
}
141141

142142
if (Is_Point_On_Segment(&commun, s1) && Is_Point_On_Segment(&commun, s2))
143-
return 1;
143+
return true;
144144

145-
return 0;
145+
return false;
146146
}
147147

148148
/****************************************************************************************
@@ -152,9 +152,9 @@ boolean Is_Point_On_Segment(Point * p, Segment *s)
152152
{
153153
if ((p->x <= max(s->p1.x,s->p2.x)) && (p->x >= min(s->p1.x,s->p2.x))
154154
&& (p->y <= max(s->p1.y,s->p2.y)) && (p->y >= min(s->p1.y,s->p2.y)))
155-
return 1;
155+
return true;
156156

157-
return 0;
157+
return false;
158158
}
159159

160160
/****************************************************************************************
@@ -205,9 +205,9 @@ Point GePoint_ProjectionOn_Segment(Point *p, Segment *s)
205205
boolean Is_Equal_Point(Point *p1, Point *p2)
206206
{
207207
if ((p1->x == p2->x) && (p1->y == p2->y))
208-
return 1;
208+
return true;
209209

210-
return 0;
210+
return false;
211211
}
212212

213213
/****************************************************************************************
@@ -226,20 +226,20 @@ boolean Is_Point_CloseTo_Segment(Point *p, Segment *s, uint16 d)
226226
Point projected;
227227

228228
// if (Get_Distance_Point(p, s.p1) <= d) // check distance from first end point
229-
// return 1;
229+
// return true;
230230
//
231231
// if (Get_Distance_Point(p, s.p2) <= d) // check distance from second end point
232-
// return 1;
232+
// return true;
233233

234234
projected = GePoint_ProjectionOn_Segment(p, s);
235235

236236
if (Is_Point_On_Segment(&projected, s))
237237
{
238238
if (Get_Distance_Point(p, &projected) <= d) // check distance from line
239-
return 1;
239+
return true;
240240
}
241241

242-
return 0;
242+
return false;
243243
}
244244

245245
/****************************************************************************************
@@ -249,8 +249,8 @@ boolean Is_Circle_CloseTo_Segment(Circle *c, Segment *s, uint16 d)
249249
{
250250
d = d + c->r;
251251
// check distance from each end point to circle
252-
if (Get_Distance_Point(&s->p1, &c->p) <= d) return 1;
253-
if (Get_Distance_Point(&s->p2, &c->p) <= d) return 1;
252+
if (Get_Distance_Point(&s->p1, &c->p) <= d) return true;
253+
if (Get_Distance_Point(&s->p2, &c->p) <= d) return true;
254254

255255
return Is_Point_CloseTo_Segment(&c->p, s, d);
256256
}
@@ -261,21 +261,21 @@ boolean Is_Circle_CloseTo_Segment(Circle *c, Segment *s, uint16 d)
261261
boolean Is_Segment_CloseTo_Segment(Segment *s1, Segment *s2, uint16 d)
262262
{
263263
// check segment intersection
264-
if (Is_Intersection_Segment(s1, s2)) return 1;
264+
if (Is_Intersection_Segment(s1, s2)) return true;
265265

266266
// // check distance from each end point to each other // manually done in excel map
267-
// if (Get_Distance_Point(&s1->p1, &s2->p1) <= d) return 1;
268-
// if (Get_Distance_Point(&s1->p1, &s2->p2) <= d) return 1;
269-
// if (Get_Distance_Point(&s1->p2, &s2->p1) <= d) return 1;
270-
// if (Get_Distance_Point(&s1->p2, &s2->p2) <= d) return 1;
267+
// if (Get_Distance_Point(&s1->p1, &s2->p1) <= d) return true;
268+
// if (Get_Distance_Point(&s1->p1, &s2->p2) <= d) return true;
269+
// if (Get_Distance_Point(&s1->p2, &s2->p1) <= d) return true;
270+
// if (Get_Distance_Point(&s1->p2, &s2->p2) <= d) return true;
271271

272272
// // check distance orthogonal from end point // manually done in excel map
273-
// if (Is_Point_CloseTo_Segment(&s1->p1, s2, d)) return 1;
274-
// if (Is_Point_CloseTo_Segment(&s1->p2, s2, d)) return 1;
275-
// if (Is_Point_CloseTo_Segment(&s2->p1, s1, d)) return 1;
276-
// if (Is_Point_CloseTo_Segment(&s2->p2, s1, d)) return 1;
273+
// if (Is_Point_CloseTo_Segment(&s1->p1, s2, d)) return true;
274+
// if (Is_Point_CloseTo_Segment(&s1->p2, s2, d)) return true;
275+
// if (Is_Point_CloseTo_Segment(&s2->p1, s1, d)) return true;
276+
// if (Is_Point_CloseTo_Segment(&s2->p2, s1, d)) return true;
277277

278-
return 0;
278+
return false;
279279
}
280280

281281
/****************************************************************************************
@@ -295,26 +295,26 @@ boolean Is_Passable_Point(Point *source, Point *target, uint16 margin)
295295
Segment edge;
296296

297297
// if (Is_Equal_Point(source, target)) // check segment existence
298-
// return 0;
298+
// return false;
299299

300300
edge = Segment(*source, *target);
301301

302302
for (i=0; i<Max_Segment; i++)
303303
{
304304
if (Is_Segment_CloseTo_Segment(&segment[i], &edge, margin)) // check segment proximity
305-
return 0;
305+
return false;
306306
}
307307

308308
for (i=0; i<Max_Circle; i++)
309309
{
310310
if (Is_NotNull_Circle(&circle[i]))
311311
{
312312
if (Is_Circle_CloseTo_Segment(&circle[i], &edge, margin)) // check circle proximity
313-
return 0;
313+
return false;
314314
}
315315
}
316316

317-
return 1; // after all checking
317+
return true; // after all checking
318318
}
319319

320320
/****************************************************************************************
@@ -331,19 +331,19 @@ boolean Is_Passable_Robot(Point *target, uint16 margin)
331331
for (i=0; i<Max_Segment; i++) // check segment proximity
332332
{
333333
// check segment intersection
334-
if (Is_Intersection_Segment(&segment[i], &edge)) return 0;
334+
if (Is_Intersection_Segment(&segment[i], &edge)) return false;
335335

336336
// // check distance from each end point to each other
337-
// //if (Get_Distance_Point(&edge.p1, &segment[i].p1) <= margin) return 0; // ignore edge.p1 = vertex[0] = robot
338-
// //if (Get_Distance_Point(&edge.p1, &segment[i].p2) <= margin) return 0;
339-
// if (Get_Distance_Point(&edge.p2, &segment[i].p1) <= margin) return 0;
340-
// if (Get_Distance_Point(&edge.p2, &segment[i].p2) <= margin) return 0;
337+
// //if (Get_Distance_Point(&edge.p1, &segment[i].p1) <= margin) return false; // ignore edge.p1 = vertex[0] = robot
338+
// //if (Get_Distance_Point(&edge.p1, &segment[i].p2) <= margin) return false;
339+
// if (Get_Distance_Point(&edge.p2, &segment[i].p1) <= margin) return false;
340+
// if (Get_Distance_Point(&edge.p2, &segment[i].p2) <= margin) return false;
341341

342342
// // check distance orthogonal from end point
343-
// if (Is_Point_CloseTo_Segment(&segment[i].p1, &edge, margin)) return 0;
344-
// if (Is_Point_CloseTo_Segment(&segment[i].p2, &edge, margin)) return 0;
345-
// //if (Is_Point_CloseTo_Segment(edge.p1, segment[i], margin)) return 0;
346-
// if (Is_Point_CloseTo_Segment(&edge.p2, &segment[i], margin)) return 0; // manually done in excel map
343+
// if (Is_Point_CloseTo_Segment(&segment[i].p1, &edge, margin)) return false;
344+
// if (Is_Point_CloseTo_Segment(&segment[i].p2, &edge, margin)) return false;
345+
// //if (Is_Point_CloseTo_Segment(edge.p1, segment[i], margin)) return false;
346+
// if (Is_Point_CloseTo_Segment(&edge.p2, &segment[i], margin)) return false; // manually done in excel map
347347
}
348348

349349
for (i=0; i<Max_Circle; i++) // check circle proximity
@@ -352,10 +352,10 @@ boolean Is_Passable_Robot(Point *target, uint16 margin)
352352
{
353353
margin_temp = margin + circle[i].r;
354354
// check distance from end point to circle
355-
//if (Get_Distance_Point(&edge.p1, &circle[i].p) <= margin_temp) return 0;
356-
if (Get_Distance_Point(&edge.p2, &circle[i].p) <= margin_temp) return 0; // usefull for vertex in circle
355+
//if (Get_Distance_Point(&edge.p1, &circle[i].p) <= margin_temp) return false;
356+
if (Get_Distance_Point(&edge.p2, &circle[i].p) <= margin_temp) return false; // usefull for vertex in circle
357357

358-
if (Is_Point_CloseTo_Segment(&circle[i].p, &edge, margin_temp)) return 0; // most important
358+
if (Is_Point_CloseTo_Segment(&circle[i].p, &edge, margin_temp)) return false; // most important
359359
}
360360
}
361361

@@ -366,14 +366,14 @@ boolean Is_Passable_Robot(Point *target, uint16 margin)
366366
if (Is_Valid_Obstacle(i))
367367
{
368368
if (Get_Distance_Point(&edge.p2, &obstacle[i].p) < margin_temp)
369-
return 0;
369+
return false;
370370

371371
if (Is_Point_CloseTo_Segment(&obstacle[i].p, &edge, margin_temp))
372-
return 0;
372+
return false;
373373
}
374374
}
375375

376-
return 1; // after all checking
376+
return true; // after all checking
377377
}
378378

379379
/****************************************************************************************

src/PathPlanning/Obstacle.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -63,27 +63,27 @@ boolean Is_False_Obstacle(Circle circle_obstacle)
6363
{
6464
uint8 i;
6565
// check map border limits
66-
if (circle_obstacle.p.x < OBSTACLE_MARGIN) return 1;
67-
if (circle_obstacle.p.x > (MAP_X_MAX - OBSTACLE_MARGIN)) return 1;
68-
if (circle_obstacle.p.y < OBSTACLE_MARGIN) return 1;
69-
if (circle_obstacle.p.y > (MAP_Y_MAX - OBSTACLE_MARGIN)) return 1;
66+
if (circle_obstacle.p.x < OBSTACLE_MARGIN) return true;
67+
if (circle_obstacle.p.x > (MAP_X_MAX - OBSTACLE_MARGIN)) return true;
68+
if (circle_obstacle.p.y < OBSTACLE_MARGIN) return true;
69+
if (circle_obstacle.p.y > (MAP_Y_MAX - OBSTACLE_MARGIN)) return true;
7070
// check some special point
7171
for (i = 0; i < MAX_FALSE_OBSTACLE; i++)
7272
{
7373
if (Get_Distance_Point(&circle_obstacle.p, &false_obstacle[i].p) <= false_obstacle[i].r)
74-
return 1;
74+
return true;
7575
}
76-
return 0;
76+
return false;
7777
}
7878

7979
boolean IsInMap(Point p)
8080
{
8181
// check map border limits
82-
if (p.x < 0) return 0;
83-
if (p.x > MAP_X_MAX) return 0;
84-
if (p.y < 0) return 0;
85-
if (p.y > MAP_Y_MAX) return 0;
86-
return 1;
82+
if (p.x < 0) return false;
83+
if (p.x > MAP_X_MAX) return false;
84+
if (p.y < 0) return false;
85+
if (p.y > MAP_Y_MAX) return false;
86+
return true;
8787
}
8888

8989
/****************************************************************************************

0 commit comments

Comments
 (0)