I have an assignment where prgram gets an integer numPoints, and doubles xlength, ylength, zlength, thenreturns 'n' random 3D data points stored in a 3D array.Where the Spatial data points should run from -xlength to +xlength, -ylength to +ylength... Im kind of confused as to what and how i am supposed to structure the program. I am using Java. Some help as to what direction I should take and tips would be great! Thanks!
Asked
Active
Viewed 72 times
1 Answers
0
This should help you generate a random double within a range. You can take the answer there and apply it to each point you're generating. Here's some pseudo code (this will not compile):
package com.sandbox;
public class Sandbox {
public static void main(String[] args) {
Double points[][][] = new Double[n][n][n];
for (int i = 0; i < n; i++) {
Point point = generateRandomPointBetweenRanges(x, y, z);
points.add(point);
}
}
Point generateRandomPointBetweenRanges(double x, double y, double z) {
xCoord = generateRandomDoubleBetweenRanges(-x, x)
yCoord = generateRandomDoubleBetweenRanges(-y, y)
...
}
}

Community
- 1
- 1

Daniel Kaplan
- 62,768
- 50
- 234
- 356