示例#1
0
        public bool CanMoveTo(double x, double y, double z)
        {
            double origX = this.x;
            double origY = this.y;
            double origZ = this.z;

            bool res = true;

            this.x = x; this.y = y; this.z = z;

            if (Tetrahedrons.Any(t => !t.CheckVolume()))
            {
                res = false;
            }

            this.x = origX;
            this.y = origY;
            this.z = origZ;

            return(res);
        }
示例#2
0
        public bool MoveTo(double x, double y, double z, bool safe)
        {
            if (!safe)
            {
                this.x = x; this.y = y; this.z = z;

                return(true);
            }
            else
            {
                double origX = this.x;
                double origY = this.y;
                double origZ = this.z;

                this.x = x; this.y = y; this.z = z;

                int p = 0;
                while (p < 20 && Tetrahedrons.Any(t => !t.CheckVolume()))
                {
                    this.x = origX + 0.9 * (this.x - origX);
                    this.y = origY + 0.9 * (this.y - origY);
                    this.z = origZ + 0.9 * (this.z - origZ);

                    p++;
                }

                if (p == 20)
                {
                    this.x = origX;
                    this.y = origY;
                    this.z = origZ;
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
        }