Binary Image Library
Data Structures | Macros | Functions
C:/Users/Malcolm/Documents/temp/binaryimagelibrary/astar.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "heap.h"

Data Structures

struct  APOINT
 

Macros

#define FILL   0x01
 
#define FILLMASK   0x01
 
#define ASET   0x02
 
#define BSET   0x04
 
#define SETMASK   0x06
 
#define NONE   0x00
 
#define NORTHWEST   0x10
 
#define NORTH   0x20
 
#define NORTHEAST   0x30
 
#define WEST   0x40
 
#define EAST   0x50
 
#define SOUTHWEST   0x60
 
#define SOUTH   0x70
 
#define SOUTHEAST   0x80
 
#define LINKMASK   0xF0
 

Functions

int astar (unsigned char *binary, int width, int height, int sx, int sy, int ex, int ey, int **pathx, int **pathy)
 

Detailed Description

A* path finding algorithm, for binary images.

It finds the path between two points by gradually expanding shells of accessible points round the two points until they meet.

Many thanks to Richard Heathfield for the heap (priority queue).

Function Documentation

int astar ( unsigned char *  binary,
int  width,
int  height,
int  sx,
int  sy,
int  ex,
int  ey,
int **  pathx,
int **  pathy 
)

A star path finding algorithm.

Parameters
[in]binary- the binary image
width- image width
height- image height
sx- start point x-coordinate
sy- start point y-coordinate
ex- end point x coordinate
ey- end point y coordinate
[out]pathx- return for x-coordinates of path (malloced)
[out]pathy- return for y-coordinates of path (malloced)
Returns
Number of path points, -1 on fail.