Example #1
0
        public static bool Intersect(this IConvex2Polytope a, IConvex2Polytope b)
        {
            if (!a.WorldBounds.Overlaps(b.WorldBounds))
            {
                return(false);
            }

            foreach (var ax in a.Normals())
            {
                if (ax.sqrMagnitude > E && !Intersect(ax, a.Vertices(), b.Vertices()))
                {
                    return(false);
                }
            }

            foreach (var bx in b.Normals())
            {
                if (bx.sqrMagnitude > E && !Intersect(bx, a.Vertices(), b.Vertices()))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        public static bool Contains(this IConvex2Polytope a, Vector2 point)
        {
            if (!a.WorldBounds.Contains(point))
            {
                return(false);
            }

            foreach (var ax in a.Normals())
            {
                if (ax.sqrMagnitude > E && !Contains(ax, a.Vertices(), point))
                {
                    return(false);
                }
            }

            return(true);
        }