From 43fed3a07ab4626a2961b850ffbb08734359e86e Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Tue, 17 Jun 2008 22:57:09 +0200 Subject: * digital/io/src: - make path independent of playground. --- digital/io/src/path.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'digital/io/src/path.c') diff --git a/digital/io/src/path.c b/digital/io/src/path.c index cf3167c4..a41a2d4e 100644 --- a/digital/io/src/path.c +++ b/digital/io/src/path.c @@ -25,7 +25,6 @@ #include "common.h" #include "path.h" -#include "playground.h" #include "simu.host.h" #include "modules/math/fixed/fixed.h" @@ -71,6 +70,8 @@ struct path_obstacle_t /** Path finding context. */ struct path_t { + /** Borders, any point outside borders is eliminated. */ + int16_t border_xmin, border_ymin, border_xmax, border_ymax; /** Complex number used to position obstacles points. * The obstacles points are placed evenly on a circle around the center * point. Complex multiplication is used to make a point rotate around @@ -94,8 +95,14 @@ struct path_t path; /** Initialise path finder. */ void -path_init (void) +path_init (int16_t border_xmin, int16_t border_ymin, + int16_t border_xmax, int16_t border_ymax) { + /** Save borders. */ + path.border_xmin = border_xmin; + path.border_ymin = border_ymin; + path.border_xmax = border_xmax; + path.border_ymax = border_ymax; /** Complex number of modulus 1 and rotation angle. */ path.rot_a = fixed_cos_f824 (PATH_OBSTACLES_POINTS_ANGLE); path.rot_b = fixed_sin_f824 (PATH_OBSTACLES_POINTS_ANGLE); @@ -131,10 +138,10 @@ path_compute_points (void) path.points[p].x = path.obstacles[i].x + (uint16_t) x; path.points[p].y = path.obstacles[i].y + (uint16_t) y; /* Check it is in playground. */ - if (path.points[p].x > PG_BORDER_DISTANCE - && path.points[p].y > PG_BORDER_DISTANCE - && path.points[p].x < PG_WIDTH - PG_BORDER_DISTANCE - && path.points[p].y < PG_HEIGHT - PG_BORDER_DISTANCE) + if (path.points[p].x >= path.border_xmin + && path.points[p].y >= path.border_ymin + && path.points[p].x < path.border_xmax + && path.points[p].y < path.border_ymax) /* Accept point. */ p++; } -- cgit v1.2.3