Created
May 1, 2018 06:59
-
-
Save HellFirePvP/c03da8559a524d0cbc1e8f2bd619b393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception { | |
File packingGen = new File(System.getProperty("user.dir"), "packing.xyzd." + System.currentTimeMillis()); | |
if(!packingGen.exists()) { | |
packingGen.createNewFile(); | |
} | |
FileOutputStream fos = new FileOutputStream(packingGen); | |
fos.write(generatePacking()); | |
fos.close(); | |
} | |
private static byte[] generatePacking() { | |
int particles = 600; | |
double min = 10, max = 50; | |
int maxX = 200, maxY = 250, maxZ = 200; | |
Random r = new Random(); | |
ByteBuffer buf = ByteBuffer.allocate(4 * 8 * particles).order(ByteOrder.LITTLE_ENDIAN); | |
for (int i = 0; i < particles; i++) { | |
double rad = min + ((max - min) * r.nextDouble()); | |
double posX = min + ((maxX - (min * 2)) * r.nextDouble()); | |
double posY = min + ((maxY - (min * 2)) * r.nextDouble()); | |
double posZ = min + ((maxZ - (min * 2)) * r.nextDouble()); | |
buf.putDouble(posX).putDouble(posY).putDouble(posZ).putDouble(rad); | |
} | |
return buf.array(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment