I'm a computer programmer and am currently coding up an algorithm. As part of the algorithm I need to take a unique ID (either a series of characters or most likely a large integer) and generate an X,Y pair from this ID within a given square/rectangle (I know the co-ordinates of each 4 boundary coordinates of the square/rectangle). These generated X,Y coordinates need to be uniformly distributed within the area and also unique so that every time I do this conversion on a particular ID I always get the same resulting X,Y pair and a conversion on any other ID does not result in the same X,Y pair.
Can anyone help me with how to approach this?
Thanks in advance.
Ok, I did this to a point by passing in a unique ID, seeding the random number generator, generating the two numbers and then scaling them (see below). The issue is that when I pass in the same ID again later I get two different numbers...This makes sense since this is what a random number generator is supposed to do in the first place but I suppose I'm a bit confused as to a way around it.
if (GHLSrnGenCreated == OPC_FALSE)
ghls_randomGenPtr = prg_random_gen_create(intndID);
GHLSrnGenCreated = OPC_TRUE;
//variant in the range [0,1]
x = prg_random_double_gen(ghls_randomGenPtr);
y = prg_random_double_gen(ghls_randomGenPtr);
hashedPosCoordinates->current_longitude = x * area_size_x;
hashedPosCoordinates->current_latitude = y * area_size_y;