:
rand1 = 0 (or 1)
rand2 = 0 (or 1)
rand3 = 0 (or 1),
. mod% 4 (-1 ), 1 - 1 0; , NaN , - 0.
Btw. , , , , , ,
:
, my height [] , init . - , ?
, , . , . (, , (x mod 4) + 1) . rand1, rand2, rand3, . , ? Sin (..)? , , , , .
int[] heights = new int[750];
public MathTest()
{
Random r = new Random();
float flat;
float peak;
flat = 70;
peak = 50;
int rand1;
int rand2;
int rand3;
int x = r.nextInt();
int y = r.nextInt();
int z = r.nextInt();
System.out.println("x : " + x);
System.out.println("y : " + y);
System.out.println("z : " + z);
System.out.println("-210263172");
System.out.println("-724188689");
System.out.println("-1092425465");
System.out.println(-210263172 % 4);
System.out.println(-724188689 % 4);
System.out.println(-1092425465 % 4);
rand1 = x % 4 + 1;
rand2 = y % 4 + 1;
rand3 = z % 4 + 1;
for( int a = 0; a < 750; a++ )
{
System.out.println("rand1: " + rand1);
System.out.println("rand2: " + rand2);
System.out.println("rand3: " + rand3);
double height =
peak / rand1 * Math.sin((double) a / flat * rand1 + rand1);
height +=
peak / rand2 * Math.sin((double) a / flat * rand2 + rand2);
height +=
peak / rand3 * Math.sin((double) a / flat * rand3 + rand3);
height += 250;
heights[a] = (int) height;
}
int i;
for(i = 0; i < 23; i++)
{
System.out.println("heights[" + i + "]: " + heights[i]);
}
}