-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPointGenerator.java
More file actions
46 lines (36 loc) · 1.32 KB
/
Copy pathPointGenerator.java
File metadata and controls
46 lines (36 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
public class PointGenerator {
private int dimensions;
private int numPoints;
public PointGenerator(int dimensions, int numPoints) {
this.dimensions = dimensions;
this.numPoints = numPoints;
}
public void generatePointsToFile(String fileName) {
try (BufferedWriter writer = new BufferedWriter(new FileWriter(fileName))) {
for (int i = 1; i <= numObjects; i++) {
double[] coordinates = new double[dimensions];
for (int j = 0; j < dimensions; j++) {
coordinates[j] = getRandomCoordinate();
}
Point point = new Point(0, coordinates);
writer.write(point.toString());
writer.newLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
private double getRandomCoordinate() {
return Math.random() * 100;
}
public static void main(String[] args) {
int dimensions = 7; // Number of dimensions for each object
int numPoints = 1000; // Number of points to create
String fileName = "Points.txt"; // Output file name
PointGenerator pointGenerator = new PointGenerator(dimensions, numPoints);
pointGenerator.generatePointsToFile(fileName);
}
}