解決策を見つけました...改善できると思います。これを行うには、次の関数を使用する必要があります。
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;
}