-3

少し助けが必要です。基本的には世界の2つの座標間のブロック数を計算したいのですが、ご覧のとおり数学が苦手なので、解決策があれば書いてください。大事なことなので書いていただけるとありがたいです!

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;
4

1 に答える 1

1

の距離が正しくありません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;
于 2014-09-28T00:38:00.083 に答える