私はpoint3Dクラスとvector3Dクラスで作業しています。ある3D点から別の3D点までの距離を一定の距離だけ調整する方法
- 点A点は座標0,0,0にある。
- 点B点は座標1,1,1に存在する。
- ベクトルAB - 2点AとBの間の長さが距離= 1.73205078であることを示すベクトルAB。
コード:
Point3D A = new Point3D { X = 0, Y = 0, Z = 0 };
Point3D B = new Point3D { X = 1, Y = 1, Z = 1 };
Vector3D AtoB = A - B;
Double distanceBetweenAandB = AtoB.Length; // the distance will be 1.73205078 here.
Iは、(位置に調整私は0.5の代わりに1に、点Aと点Bとの間の距離を短くしたい点Bを調整したいですC)。私はこれを行う方法を解決しようとしています。
点A(0,0,0)は既知であり、点B(1,1,1)は既知であり、調整する距離は既知である(0.5)。どのように計算しますか?
は擬似コード:以下の図に示す
Point3D A = new Point3D { X = 0, Y = 0, Z = 0 };
Point3D B = new Point3D { X = 1, Y = 1, Z = 1 };
Double distanceToAdjust = 0.5;
Point3D newCoordinate = B - distanceToAdjust; // this doesnt work!
調整ポイントB:私は私自身を使用しています
はPoint3DのクラスとのVector3Dクラスを定義しました。
ベクトル[1 1 1]の長さは1ではなく、 'SQRT(3)= 1.732(...)'です。 –