//
        // Are two triangles intersecting in 2d space
        //
        public static bool TriangleTriangle2D(Triangle2 t1, Triangle2 t2, bool do_AABB_test)
        {
            bool isIntersecting = false;

            //Step 0. AABB intersection which may speed up the algorithm if the triangles are far apart
            if (do_AABB_test)
            {
                //Rectangle that covers t1
                AABB2 r1 = new AABB2(t1.MinX(), t1.MaxX(), t1.MinY(), t1.MaxY());

                //Rectangle that covers t2
                AABB2 r2 = new AABB2(t2.MinX(), t2.MaxX(), t2.MinY(), t2.MaxY());

                if (!AABB_AABB_2D(r1, r2))
                {
                    return(false);
                }
            }


            //Step 1. Line-line instersection

            //Line 1 of t1 against all lines of t2
            if (
                LineLine(t1.p1, t1.p2, t2.p1, t2.p2, true) ||
                LineLine(t1.p1, t1.p2, t2.p2, t2.p3, true) ||
                LineLine(t1.p1, t1.p2, t2.p3, t2.p1, true)
                )
            {
                isIntersecting = true;
            }
            //Line 2 of t1 against all lines of t2
            else if (
                LineLine(t1.p2, t1.p3, t2.p1, t2.p2, true) ||
                LineLine(t1.p2, t1.p3, t2.p2, t2.p3, true) ||
                LineLine(t1.p2, t1.p3, t2.p3, t2.p1, true)
                )
            {
                isIntersecting = true;
            }
            //Line 3 of t1 against all lines of t2
            else if (
                LineLine(t1.p3, t1.p1, t2.p1, t2.p2, true) ||
                LineLine(t1.p3, t1.p1, t2.p2, t2.p3, true) ||
                LineLine(t1.p3, t1.p1, t2.p3, t2.p1, true)
                )
            {
                isIntersecting = true;
            }

            //Now we can return if we are intersecting so we dont need to spend time testing something else
            if (isIntersecting)
            {
                return(isIntersecting);
            }


            //Step 2. Point-in-triangle intersection
            //We only need to test one corner from each triangle
            //If this point is not in the triangle, then the other points can't be in the triangle, because if this point is outside
            //and another point is inside, then the line between them would have been covered by step 1: line-line intersections test
            if (PointTriangle(t2, t1.p1, true) || PointTriangle(t1, t2.p1, true))
            {
                isIntersecting = true;
            }


            return(isIntersecting);
        }