public GenericBlockDesign calculateLightSources() {
lightSourceXOffset = new int[xPos.length];
lightSourceYOffset = new int[xPos.length];
lightSourceZOffset = new int[xPos.length];
for (int quad = 0; quad < xPos.length; quad++) {
BlockVector normal = new BlockVector();
normal.setX(((yPos[quad][0] - yPos[quad][1]) * (zPos[quad][1] - zPos[quad][2])) - ((zPos[quad][0] - zPos[quad][1]) * (yPos[quad][1] - yPos[quad][2])));
normal.setY(((zPos[quad][0] - zPos[quad][1]) * (xPos[quad][1] - xPos[quad][2])) - ((xPos[quad][0] - xPos[quad][1]) * (zPos[quad][1] - zPos[quad][2])));
normal.setZ(((xPos[quad][0] - xPos[quad][1]) * (yPos[quad][1] - yPos[quad][2])) - ((yPos[quad][0] - yPos[quad][1]) * (xPos[quad][1] - xPos[quad][2])));
Double length = Math.sqrt((normal.getX() * normal.getX()) + (normal.getY() * normal.getY()) + (normal.getZ() * normal.getZ()));
this.setLightSource(quad, (int) Math.round(normal.getX() / length), (int) Math.round(normal.getY() / length), (int) Math.round(normal.getZ() / length));
}
return this;
}