Loading src/main/java/Graph/readFile.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ public class readFile { public static Map<VertexKey,Integer> vertexToIndex = new HashMap<>(); public static Map<Integer, VertexKey> indexToVertex = new HashMap<>(); public static float[] vertices; private static ArrayList<Integer> faces = new ArrayList<>(); public static AdjacencyMatrix adjMatrix; Loading Loading @@ -228,8 +230,24 @@ public class readFile { */ private static String makeLine(Random random) { return String.format("[%f,%f,%f] [%f,%f,%f] [%f,%f,%f]", random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30); vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3]); } public static void generateRandomVertices(int numVertices) { float range = 30; Random random = new Random(); vertices = new float[numVertices * 3]; for (int i = 0; i < numVertices * 3; i += 3) { float x = (random.nextFloat() * range); float y = (random.nextFloat() * range); float z = (random.nextFloat() * range); // Ensures the value stays within range vertices[i] = Math.max(0, Math.min(range, x)); vertices[i + 1] = Math.max(0, Math.min(range, y)); vertices[i + 2] = Math.max(0, Math.min(range, z)); } } } src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class GraphicsAndWindowsTest extends Application { }; parameters = getParameters().getRaw().toArray(new String[getParameters().getRaw().size()]); readFile.generateRandomVertices(1000); readFile.randFileGenerator("testfile2.txt"); readFile processInput = new readFile(); processInput.parseCommand(parameters); Loading Loading
src/main/java/Graph/readFile.java +21 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ public class readFile { public static Map<VertexKey,Integer> vertexToIndex = new HashMap<>(); public static Map<Integer, VertexKey> indexToVertex = new HashMap<>(); public static float[] vertices; private static ArrayList<Integer> faces = new ArrayList<>(); public static AdjacencyMatrix adjMatrix; Loading Loading @@ -228,8 +230,24 @@ public class readFile { */ private static String makeLine(Random random) { return String.format("[%f,%f,%f] [%f,%f,%f] [%f,%f,%f]", random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30, random.nextFloat() * 30); vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3], vertices[random.nextInt(vertices.length / 3) * 3]); } public static void generateRandomVertices(int numVertices) { float range = 30; Random random = new Random(); vertices = new float[numVertices * 3]; for (int i = 0; i < numVertices * 3; i += 3) { float x = (random.nextFloat() * range); float y = (random.nextFloat() * range); float z = (random.nextFloat() * range); // Ensures the value stays within range vertices[i] = Math.max(0, Math.min(range, x)); vertices[i + 1] = Math.max(0, Math.min(range, y)); vertices[i + 2] = Math.max(0, Math.min(range, z)); } } }
src/main/java/org/example/newmat/GraphicsAndWindowsTest.java +1 −0 Original line number Diff line number Diff line Loading @@ -62,6 +62,7 @@ public class GraphicsAndWindowsTest extends Application { }; parameters = getParameters().getRaw().toArray(new String[getParameters().getRaw().size()]); readFile.generateRandomVertices(1000); readFile.randFileGenerator("testfile2.txt"); readFile processInput = new readFile(); processInput.parseCommand(parameters); Loading