/*
 * 2007+ Copyright (c) Evgeniy Polyakov <johnpol@2ka.mipt.ru>
 * All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 */

#ifndef __SKY_H
#define __SKY_H

#include "rbtree.h"
#include "list.h"

struct sky_xy
{
	struct rb_node		rb_node;
	double			x, y;
};

struct sky_param
{
	double			cos_b, sin_b;
	double			len;
};

struct sky_map
{
	struct rb_root		rb_root;
	unsigned int		num, maxx, maxy;
	struct sky_xy		*coords;
};

struct sky_graph
{
	struct sky_map		*map;
	
	struct list_head	found_list;
	pthread_mutex_t 	found_lock;

	unsigned int		start, end;

	double			vector_len;
	struct sky_param	*pc;
};

struct sky_found_object
{
	struct list_head	found_entry;
	unsigned int		c, e;
};

struct sky_map *sky_gen_map(unsigned int num, unsigned int seed,
		double maxx, double maxy);
struct sky_graph *sky_gen_graph(struct sky_map *map,
		unsigned int start, unsigned int end);
int sky_search_map(struct sky_map *map, struct sky_graph *pat,
		unsigned int pos, unsigned int num);

#endif /* __SKY_H */

