Esempio n. 1
0
        public override PointedSubspace IntersectedWith(PointedSubspace other)
        {
            if (other.Snap(Vector3.zero) == Vector3.zero)
            {
                return(new PointedSubspace(IntersectedWith(other.subspace), Vector3.zero));
            }

            if (other.subspace is Subspace1)
            {
                Vector3?intersect = _intersect_plane_line(
                    normal, Vector3.zero,
                    other.point0, ((Subspace1)other.subspace).axis);
                if (intersect.HasValue)
                {
                    return(new PointedSubspace(new Subspace0(), intersect.Value));
                }
            }
            else if (other.subspace is Subspace2)
            {
                Subspace ss = other.subspace.NormalSubspace().JoinedWithVector(normal);
                if (ss is Subspace2)
                {
                    Vector3         intersect_normal = ((Subspace2)ss).normal;
                    Subspace        ss2  = IntersectedWithPlane(intersect_normal); /* a Subspace1 */
                    PointedSubspace pss2 = ss2.IntersectedWith(other);
                    return(new PointedSubspace(ss.NormalSubspace(), pss2.point0));
                }
            }
            return(PointedSubspace.Void());
        }
Esempio n. 2
0
        public PointedSubspace IntersectedWith(PointedSubspace other)
        {
            if (IsEmpty())
            {
                return(this);
            }
            if (other.IsEmpty())
            {
                return(other);
            }

            var res = subspace.IntersectedWith(new PointedSubspace(other.subspace, other.point0 - point0));

            return(new PointedSubspace(res.subspace, res.point0 + point0));
        }