オブジェクト空間で中心点と半径で表される球があります。球は、スケール、回転、および平行移動を含む可能性のある変換行列を使用して、ワールド空間に変換されます。ワールドスペースで球の軸に沿ったバウンディングボックスを作成する必要がありますが、その方法がわかりません。
これが私の現在のアプローチであり、いくつかのケースで機能します。
public void computeBoundingBox() {
// center is the middle of the sphere
// averagePosition is the middle of the AABB
// getObjToWorldTransform() is a matrix from obj to world space
getObjToWorldTransform().rightMultiply(center, averagePosition);
Point3 onSphere = new Point3(center);
onSphere.scaleAdd(radius, new Vector3(1, 1, 1));
getObjToWorldTransform().rightMultiply(onSphere);
// but how do you know that the transformed radius is uniform?
double transformedRadius = onSphere.distance(averagePosition);
// maxBound is the upper limit of the AABB
maxBound.set(averagePosition);
maxBound.scaleAdd(transformedRadius, new Vector3(1, 1, 1));
// minBound is the lower limit of the AABB
minBound.set(averagePosition);
minBound.scaleAdd(transformedRadius, new Vector3(-1,-1,-1));
}
しかし、私はこれが常に機能するのではないかと疑っています。不均一なスケーリングで失敗するべきではありませんか?