@ Pure public static boolean intersectsTriangleOrientedBox ( double tx1 , double ty1 , double tz1 , double tx2 , double ty2 , double tz2 , double tx3 , double ty3 , double tz3 , double cx , double cy , double cz , double ax1 , double ay1 , double az1 , double ax2 , double ay2 , double az2 , double ax3 , double ay3 , double az3 , double ae1 , double ae2 , double ae3 ) { double nx , ny , nz ; // Translate the triangle into the oriented box frame. nx = tx1 - cx ; ny = ty1 - cy ; nz = tz1 - cz ; double ntx1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz1 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; nx = tx2 - cx ; ny = ty2 - cy ; nz = tz2 - cz ; double ntx2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz2 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; nx = tx3 - cx ; ny = ty3 - cy ; nz = tz3 - cz ; double ntx3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax1 , ay1 , az1 ) ; double nty3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax2 , ay2 , az2 ) ; double ntz3 = FunctionalVector3D . dotProduct ( nx , ny , nz , ax3 , ay3 , az3 ) ; // Test intersection return intersectsTriangleAlignedBox ( ntx1 , nty1 , ntz1 , ntx2 , nty2 , ntz2 , ntx3 , nty3 , ntz3 , - ae1 , - ae2 , - ae3 , ae1 , ae2 , ae3 ) ; }
Replies if the triangle intersects the oriented box .