public bool _SatForAxes(double[] axes, Vector3 testAxis, Vector3 extents, Vector3 v0, Vector3 v1, Vector3 v2) { int i, j; for (i = 0, j = axes.Length - 3; i <= j; i += 3) { testAxis.FromArray(axes, i); // project the aabb onto the seperating axis var r = extents.x * _Math.Abs(testAxis.x) + extents.y * _Math.Abs(testAxis.y) + extents.z * _Math.Abs(testAxis.z); // project all 3 vertices of the triangle onto the seperating axis var p0 = v0.Dot(testAxis); var p1 = v1.Dot(testAxis); var p2 = v2.Dot(testAxis); // actual test, basically see if either of the most extreme of the triangle points intersects r if (_Math.Max(-_Math.Max(_Math.Max(p0, p1), p2), _Math.Min(_Math.Min(p0, p1), p2)) > r) { // points of the projected triangle are outside the projected half-length of the aabb // the axis is seperating and we can exit return(false); } } return(true); }