/// <summary>
        /// Constructs the parallelogram by the corner and two sides.
        /// </summary>
        /// <param name="corner">the corner</param>
        /// <param name="sideA">a side</param>
        /// <param name="sideB">another side</param>
        public Parallelogram(Point corner, Point sideA, Point sideB) {

            this.corner = corner;
            this.a = sideA;
            this.b = sideB;

            this.aRot = new Point(-sideA.Y, sideA.X);
            if (aRot.Length > 0.5)
                aRot = aRot.Normalize();

            this.bRot = new Point(-sideB.Y, sideB.X);
            if (bRot.Length > 0.5)
                bRot = bRot.Normalize();

            abRot = sideA * bRot;

            baRot = sideB * aRot;


            if (abRot < 0) {
                abRot = -abRot;
                bRot = -bRot;
            }

            if (baRot < 0) {
                baRot = -baRot;
                aRot = -aRot;
            }


            isSeg = (sideA - sideB).Length < ApproximateComparer.DistanceEpsilon;

            aPlusCorner = sideA + corner;
            otherCorner =  sideB +aPlusCorner;
            bPlusCorner = sideB + corner;
        }
        internal Parallelogram(Parallelogram box0, Parallelogram box1) {
            Point v = box0.Corner;
            double minX, maxX, minY, maxY;
            minX = maxX = v.X;
            minY = maxY = v.Y;


            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box0.aPlusCorner);
            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box0.otherCorner);
            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box0.bPlusCorner);

            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box1.corner);
            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box1.aPlusCorner);
            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box1.otherCorner);
            PumpMinMax(ref minX, ref maxX, ref minY, ref maxY, ref box1.bPlusCorner);

            this.corner = new Point(minX, minY);
            this.a = new Point(0, maxY - minY);
            this.b = new Point(maxX - minX, 0);

            aPlusCorner = a + corner;
            otherCorner = b + aPlusCorner;
            bPlusCorner = b + corner;

            this.aRot = new Point(-this.a.Y, this.a.X);
            if (aRot.Length > 0.5)
                aRot = aRot.Normalize();

            this.bRot = new Point(-this.b.Y, this.b.X);
            if (bRot.Length > 0.5)
                bRot = bRot.Normalize();

            abRot = this.a * bRot;
            baRot = this.b * aRot;


            if (abRot < 0) {
                abRot = -abRot;
                bRot = -bRot;
            }

            if (baRot < 0) {
                baRot = -baRot;
                aRot = -aRot;
            }

            isSeg = (this.a - this.b).Length < ApproximateComparer.DistanceEpsilon;
        }
示例#3
0
文件: Core.cs 项目: HungryBear/rayden
 public virtual float Density(ref Point Pobj) {
     return 0.1f * (1f / NoiseProvider.Instance.Noise((Vector)Pobj.Normalize()));
 }