1

レッスン 17 で示した「カスタム スライス」を特定の位置に配置したいと考えています。そのためには、法線を変更し (完了)、スライスを特定の点 P(x,y,z) に変換する必要があります。

現在の法線によってスライス インデックスの値が大きく異なることに気付きましたが、原因がわかりません。これは私の質問を解決するのに役立ちます。

確かに、スライスはポイント P を正確に通過しない可能性がありますが、特定のインデックスに最も近いスライスは問題ありません。

私は何をする必要がありますか?

画像は私の質問を説明しています:

https://www.dropbox.com/s/48nhwg01dwhee0n/newindexvalue.png

前もって感謝します!!

4

1 に答える 1

0

解決策を見つけました...改善できると思います。これを行うには、次の関数を使用する必要があります。

GetSliceIndex_givenNormalAndPoint = function(sliceNormal,volumeCenter,sliceSpacing,indexSliceOnCenter,point){
  //Plane ecuation of the slice on the volume center point
  //Plane Ecuation given plane normal and point---Ax+By+Cz+D=0
  A = sliceNormal[0];
  B = sliceNormal[1];
  C = sliceNormal[2];
  D = -(sliceNormal[0]*volumeCenter[0]+sliceNormal[1]*volumeCenter[1]+sliceNormal[2]*volumeCenter[2]);
  //Distance between a plane and a Point
  distance = Math.abs(A*point[0]+B*point[1]+C*point[2] + D);
  distance = distance/Math.sqrt(A*A+B*B+C*C);
  //get the number of Slices on the Distance
  nSlicesOnDistance = distance/sliceSpacing;
  //get the indexSlice nearest to the point
  indexSliceOnPoint = indexSliceOnCenter + nSlicesOnDistance;
  return indexSliceOnPoint;
}

呼び出し元の例は次のとおりです。

var sliceIndex = _this.GetSliceIndex_givenNormalAndPoint(_this.volume._childrenInfo[0]._sliceNormal,
                                        _this.centerVolume,
                                        _this.volume._childrenInfo[0]._sliceSpacing,
                                        Math.floor(_this.volume._childrenInfo[0]._nb/2),
                                        _this.pointToPositioningTheSlice
                                        );
_this.volume.indexX = sliceIndex;

_this.centerVolume、ボリューム バウンディング ボックスを使用して取得されます。これ_this.pointToPositioningTheSliceは、スライスを設定するポイントです。これMath.floor(_this.volume._childrenInfo[0]._nb/2)は現在の indexX です。

結果のスクリーンショット:

https://dl.dropboxusercontent.com/u/269301/SliceOnPoint.png

よろしく!


EDIT1...インデックス位置を調整するための前のコードの修正:

xslicegui.prototype.GetSliceIndex_givenNormalAndPoint = function(sliceNormal,volumeCenter,sliceSpacing,indexSliceOnCenter,point){
  //Plane ecuation of the slice on the volume center point
  //Plane Ecuation given plane normal and point---Ax+By+Cz+D=0
  A = sliceNormal[0];
  B = sliceNormal[1];
  C = sliceNormal[2];
  D = -(sliceNormal[0]*volumeCenter[0]+sliceNormal[1]*volumeCenter[1]+sliceNormal[2]*volumeCenter[2]);
  //Distance between a plane and a Point
  distanceSigned = A*point[0]+B*point[1]+C*point[2] + D;
  distance = Math.abs(distanceSigned);
  distance = distance/Math.sqrt(A*A+B*B+C*C);
  //get the number of Slices on the Distance
  nSlicesOnDistance = distance/sliceSpacing;

  //http://stackoverflow.com/questions/15688232/check-which-side-of-a-plane-points-are-on
  sign = typeof distanceSigned === 'number' ? distanceSigned ? distanceSigned < 0 ? -1 : 1 : distanceSigned === distanceSigned ? 0 : NaN : NaN;
  //get the indexSlice nearest to the point
  indexSliceOnPoint = indexSliceOnCenter + (sign * nSlicesOnDistance);
  return indexSliceOnPoint;
}
于 2014-02-11T05:24:11.617 に答える