Пример #1
0
        public static bool Contains(this IConvex3Polytope a, Vector3 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);
        }
Пример #2
0
        public static bool Intersect(this IConvex3Polytope a, IConvex3Polytope b)
        {
            if (!a.WorldBounds().Intersects(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);
                }
            }

            foreach (var ae in a.Edges())
            {
                foreach (var be in b.Edges())
                {
                    var cx = Vector3.Cross(ae, be);
                    if (cx.sqrMagnitude > E && !Intersect(cx, a.Vertices(), b.Vertices()))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }