Skip to content

Instantly share code, notes, and snippets.

@PsichiX
Created March 16, 2015 21:47
Show Gist options
  • Save PsichiX/40648639bc154f546201 to your computer and use it in GitHub Desktop.
Save PsichiX/40648639bc154f546201 to your computer and use it in GitHub Desktop.
testPointInBox3d
public static bool testPointInBox3d(Vector3d point, Matrix boxTransformWorld, Vector3d boxDimension, Vector3d boxOrigin)
{
Matrix worldToLocalTransform = boxTransformWorld.inverse();
Vector3d localPoint = worldToLocalTransform.transform(point);
return localPoint.x >= -boxOrigin.x && localPoint.x <= boxDimension.x - boxOrigin.x &&
localPoint.y >= -boxOrigin.y && localPoint.y <= boxDimension.y - boxOrigin.y &&
localPoint.z >= -boxOrigin.z && localPoint.z <= boxDimension.z - boxOrigin.z;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment