필자는 객체 공간에서 중심점과 반지름으로 표현 된 구를 가지고 있습니다. 구체는 스케일, 회전 및 변환을 포함 할 수있는 변형 행렬로 세계 공간으로 변형됩니다. 월드 공간에서 구의 바운딩 박스를 만들 필요가 있지만 어떻게해야할지 모르겠습니다.변환 된 구체에 대한 AABB 계산
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));
}
그러나, 나는이 항상 작동 것이라고 회의적 :
는 여기에 몇 가지 경우에 작동 나의 현재의 접근 방식이다. 균일하지 않은 스케일링에 실패하면 안됩니까?
어떤 언어입니까? (자바처럼 보입니다.) – BoltClock
C#처럼 보이지만 실제로는 언어에 무관심한 질문입니다. – bobobobo