00001 00002 /*--------------------------------------------------------------------------- 00003 E.S.O. 00004 ---------------------------------------------------------------------------- 00005 File name : random_points.c 00006 Author : Nicolas Devillard 00007 Created on : April 01, 1998 00008 Language : ANSI C 00009 Description : Random point generation routines 00010 NB : These functions are replicated in poisson.c 00011 For some reason, poisson.c needs to be independent 00012 from the eclipse library routines, thus a need for 00013 replication. 00014 ---------------------------------------------------------------------------*/ 00015 00016 /* 00017 00018 $Id: random_points.h,v 1.1 2003/09/03 12:50:47 amodigli Exp $ 00019 $Author: amodigli $ 00020 $Date: 2003/09/03 12:50:47 $ 00021 $Revision: 1.1 $ 00022 00023 */ 00024 00025 #ifndef _RANDOM_POINTS_H_ 00026 #define _RANDOM_POINTS_H_ 00027 00028 /*--------------------------------------------------------------------------- 00029 * Includes 00030 *--------------------------------------------------------------------------*/ 00031 00032 #include <stdio.h> 00033 #include <stdlib.h> 00034 #include <unistd.h> 00035 00036 #include "memory.h" 00037 00038 /* 00039 * The following only gets the definition of what a 'dpoint' is 00040 */ 00041 #include "local_types.h" 00042 00043 00044 /*--------------------------------------------------------------------------- 00045 * Function codes 00046 *--------------------------------------------------------------------------*/ 00047 00048 /* 00049 * Computes the square of an euclidean distance between two points 00050 * in an euclidean plane. 00051 */ 00052 00053 double pdist(dpoint *p1, dpoint *p2) ; 00054 00055 /* 00056 * POISSON POINT GENERATION 00057 * 00058 * Without homogeneity factor, the idea is to generate a set of np 00059 * points within a given rectangle defined by (xmin xmax ymin ymax). 00060 * All these points obey a Poisson law, i.e. no couple of points is 00061 * closer to each other than a minimal distance. This minimal distance 00062 * is defined as a function of the input requested rectangle and the 00063 * requested number of points to generate. We apply the following 00064 * formula: 00065 * 00066 * dmin = sqrt( W * H / np * sqrt(2) ) 00067 * Where W and H stand for the rectangle width and height 00068 * 00069 * This ensures a global homogeneity in the output point set. 00070 * 00071 * With a specified homogeneity factor h (2 < h <= np), the generation 00072 * algorithm is different. The definition of h is: 00073 * the Poisson law applies for any h consecutive points in the final 00074 * output, but not for the whole point set. This enables us to generate 00075 * groups of points which statisfy the Poisson law, without constraining 00076 * the whole set. This actually is equivalent to dividing the rectangle 00077 * in h regions of equal surface, and generate points randomly in each 00078 * of these region, changing region at each point. 00079 * It is possible to visualize this behaviour by plotting e.g. 00080 * poisson -h 9 -n 1000 00081 * (generates 1000 points in 9 patches) 00082 * 00083 */ 00084 00085 dpoint * generate_poisson_points(rectangle * r, int np, int homog) ; 00086 00087 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001