我需要一个方法来获得圆的点获得点,我有一个,我在网上找到但不幸的是我想添加填充它一个布尔值:的Java:布尔一圈充满
public static Location[] getCylinderAt(Location loc, int r, int height) {
ArrayList<Location> list = new ArrayList<>();
int cx = loc.getBlockX();
int cy = loc.getBlockY();
int cz = loc.getBlockZ();
World w = loc.getWorld();
int rSquared = r * r;
for (int x = cx - r; x <= cx + r; x++) {
for (int y = cy - height; y <= cy + height; y++) {
for (int z = cz - r; z <= cz + r; z++) {
if ((cx - x) * (cx - x) + (cz - z) * (cz - z) <= rSquared) {
list.add(new Location(w, x, y, z));
}
}
}
}
return list.toArray(new Location[list.size()]);
}
我无法真正理解数学中涉及到的数学问题,并一直在寻找非Minecraft资源来创建我自己的,但无济于事。
理想情况下,我想能够在方法改成这样:
public static Location[] getCylinderAt(Location loc, boolean filled, int r, int height)
谢谢你们!如果你喜欢,我可以删除所有的Minecraft引用,但我不认为这是必要的,因为一个位置基本上是一个只有几个添加了我的世界唯一变量的Vector!
感谢您的阅读:)
额外参数的目的是什么? –
对不起,为了使阵列只包含外部圆柱体而不是其中的每个点 –
请解释“填充”的概念,您是在圆周上还是在圆盘表面上搜索圆周上的点? – Aubin