public double[] calculateDxDy(int cx, int cy, double vx, double vy) {
		int ci = getI(cx);
		int cj = getJ(cy);

		double dx = 0;
		double dy = 0;

		if (ci + 1 < voxels.length)
			dx = voxels[ci + 1][cj] - voxels[ci][cj];
		if (ci - 1 > 0)
			dx += voxels[ci][cj] - voxels[ci - 1][cj];
		if (cj + 1 < voxels[0].length)
			dy = voxels[ci][cj + 1] - voxels[ci][cj];
		if (cj - 1 > 0)
			dy += voxels[ci][cj] - voxels[ci][cj - 1];

		dx *= -1;
		dy *= -1;

		double dangle = Math.atan2(dy, dx);
		double vangle = Math.atan2(vy, vx);

		if (Math.abs(dangle + Math.PI - vangle) < Math.PI / 2
				|| Math.abs(dangle - Math.PI - vangle) < Math.PI / 2) {

			double diff = 0;
			if (Math.abs(dangle + Math.PI - vangle) < Math.PI / 2)
				diff = dangle + Math.PI - vangle;

			if (Math.abs(dangle - Math.PI - vangle) < Math.PI / 2)
				diff = dangle - Math.PI - vangle;

			double mag = Math.sqrt(dx * dx + dy * dy);
			if (diff < 0) {
				dangle -= (Math.PI / 2 - Math.abs(diff)) / 3;
			} else {
				dangle += (Math.PI / 2 - Math.abs(diff)) / 3;
			}
			dx = Math.cos(dangle) * mag;
			dy = Math.sin(dangle) * mag;
		}

		dx /= 2 * voxel_size;
		dy /= 2 * voxel_size;

		return new double[] { dx, dy };
	}