我需要一点帮助。 我基本上想计算世界上两个坐标之间的 block 数,但正如你所见,我不太擅长数学,所以如果你有解决方案,请写给我。 这很重要,所以请写下来,我将不胜感激!
int x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
x2 = x // pos x in the coord
y2 = y // pos y in the coord
z2 = z // pos z in the coord
x1 = x;
y1 = y;
z1 = z;
int a = Math.abs(Math.abs(x1)-(Math.abs(x2)));
int b = Math.abs(Math.abs(y1)-(Math.abs(y2)));
int c = Math.abs(Math.abs(z1)-(Math.abs(z2)));
if(x2 != 0)
int volume = a*b*c;
最佳答案
a、b、c
的距离不正确。
// int a = Math.abs(Math.abs(x1)-(Math.abs(x2)));
int a = Math.abs(x1 - x2);
当然,正如 @Ted Hopp 所指出的,代码需要一些除 0 之外的有趣值来完成很多工作。
int x1 = 0, y1 = 0, z1 = 0, x2 = 0, y2 = 0, z2 = 0;
关于java - 计算 2 个坐标之间的立方体积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26080344/