sphere box test
This commit is contained in:
parent
78f5b85d24
commit
277f88c00c
2 changed files with 8 additions and 4 deletions
|
|
@ -202,9 +202,9 @@ namespace Crafter {
|
||||||
|
|
||||||
// Translate the sphere center into the OBB's local space
|
// Translate the sphere center into the OBB's local space
|
||||||
Vector<T, 3, 0> localCenter = Vector<T, 3, 0>(
|
Vector<T, 3, 0> localCenter = Vector<T, 3, 0>(
|
||||||
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), xAxis),
|
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), xAxis),
|
||||||
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), yAxis),
|
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), yAxis),
|
||||||
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[3][0], boxMatrix.m[3][1], boxMatrix.m[3][2]), zAxis)
|
Vector<T, 3, 0>::Dot(sphereCenter - Vector<T, 3, 0>(boxMatrix.m[0][3], boxMatrix.m[1][3], boxMatrix.m[2][3]), zAxis)
|
||||||
);
|
);
|
||||||
|
|
||||||
// Clamp the local center to the OBB's extents
|
// Clamp the local center to the OBB's extents
|
||||||
|
|
|
||||||
|
|
@ -5,5 +5,9 @@ import std;
|
||||||
using namespace Crafter;
|
using namespace Crafter;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
Vector<float, 3, 0> sphereCenter(-10,0,0);
|
||||||
|
float sphereRadius = 10;
|
||||||
|
Vector<float, 3, 0> boxSize(0,0,0);
|
||||||
|
MatrixRowMajor<float, 4, 3, 1> boxMatrix = MatrixRowMajor<float, 4, 3, 1> ::Translation(10,0,0);
|
||||||
|
std::cout << IntersectionTestSphereOrientedBox(sphereCenter, sphereRadius, boxSize, boxMatrix) << std::endl;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue