示例#1
0
        public static bool Intersect2D(this IHas <IQuboidPlaceLogic> quboidPlace, IHas <IQuboidPlaceLogic> otherQuboidPlace)
        {
            if (
                (quboidPlace.Back() >= otherQuboidPlace.Front()) || (quboidPlace.Front() <= otherQuboidPlace.Back()) ||
                (quboidPlace.Left() >= otherQuboidPlace.Right()) || (quboidPlace.Right() <= otherQuboidPlace.Left())
                )
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        //public static void Rotate(this IHas<IQuboidPlaceLogic> place, int direction)
        //{
        //    var left = place.Left;
        //    var back = place.Back;
        //    var length = place.Length;
        //    switch (direction)
        //    {
        //        case 0:
        //            break;
        //        case 1:
        //            place.Back = -left - place.Width;
        //            place.Left = back;
        //            place.Length = place.Width;
        //            place.Width = length;
        //            break;
        //        case 2:
        //            place.Back = -back - place.Length;
        //            place.Left = -left - place.Width;
        //            break;
        //        case 3:
        //            place.Back = left;
        //            place.Left = -back - place.Length;
        //            place.Length = place.Width;
        //            place.Width = length;
        //            break;
        //        default:
        //            break;
        //    }
        //}
        public static void Enclose(this IHas <IQuboidPlaceLogic> quboidplace, IHas <IQuboidPlaceLogic> placeToEnclose)
        {
            double right = quboidplace.Right();
            double front = quboidplace.Front();
            double up    = quboidplace.Up();

            quboidplace.Left(Math.Min(quboidplace.Left(), placeToEnclose.Left()));
            quboidplace.Back(Math.Min(quboidplace.Back(), placeToEnclose.Back()));
            quboidplace.Down(Math.Min(quboidplace.Down(), placeToEnclose.Down()));
            quboidplace.Width(Math.Max(right, placeToEnclose.Right()) - quboidplace.Left());
            quboidplace.Length(Math.Max(front, placeToEnclose.Front()) - quboidplace.Back());
            quboidplace.Height(Math.Max(up, placeToEnclose.Up()) - quboidplace.Down());
        }
示例#3
0
 public static bool IsInside(this IHas <IQuboidPlaceLogic> quboidPlace, IHas <IQuboidPlaceLogic> otherQuboidPlace)
 {
     if (otherQuboidPlace.Back() <= quboidPlace.Back())
     {
         if (otherQuboidPlace.Front() >= quboidPlace.Front())
         {
             if (otherQuboidPlace.Left() <= quboidPlace.Left())
             {
                 if (otherQuboidPlace.Right() >= quboidPlace.Right())
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
示例#4
0
        //public static void Init(this IHas<IQuboidPlaceLogic> quboidplace, IHas<IPlaceLogic> place, IHas<IPackageLogic> package, bool alignLeft)
        //{
        //    if (alignLeft)
        //    {
        //        quboidplace.Left(place.Left());
        //    }
        //    else
        //    {
        //        quboidplace.Left(place.Right() - package.Logic.Width());
        //    }
        //    quboidplace.Back(place.Back());
        //    quboidplace.Down(place.Down());
        //    quboidplace.Length(package.Logic.Length());
        //    quboidplace.Height(package.Logic.Height());
        //    quboidplace.Width(package.Logic.Width());
        //}

        public static double GravityLength(this IHas <IQuboidPlaceLogic> qplace)
        {
            return((qplace.Back() + qplace.Front()) / 2);
        }