Exemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns the distance from this <code>Point</code> to a
         * specified <code>Point</code>.
         *
         * @param pt the specified point to be measured
         *           against this <code>Point</code>
         * @return the distance between this <code>Point</code> and
         * the specified <code>Point</code>.
         */
        public int Distance(Point pt)
        {
            int  px    = pt.GetX() - GetX();
            int  py    = pt.GetY() - GetY();
            long disSq = px * px + py * py;
            long dis   = MathFP.Sqrt(disSq << MathFP.DEFAULT_PRECISION);

            return(MathFP.ToInt(dis));
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns the distance from this <code>Point</code> to
         * a specified point.
         *
         * @param px the X coordinate of the specified point to be measured
         *           against this <code>Point</code>
         * @param py the Y coordinate of the specified point to be measured
         *           against this <code>Point</code>
         * @return the distance between this <code>Point</code>
         * and a specified point.
         */
        public int Distance(int px, int py)
        {
            px -= GetX();
            py -= GetY();
            long disSq = px * px + py * py;
            long dis   = MathFP.Sqrt(disSq << MathFP.DEFAULT_PRECISION);

            return(MathFP.ToInt(dis));
        }
Exemplo n.º 3
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 13JUN2009  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * Returns the distance between two points.
         *
         * @param x1 the X coordinate of the first specified point
         * @param y1 the Y coordinate of the first specified point
         * @param X2 the X coordinate of the second specified point
         * @param y2 the Y coordinate of the second specified point
         * @return the distance between the two sets of specified
         * coordinates.
         */
        public static int Distance(int x1, int y1,
                                   int x2, int y2)
        {
            x1 -= x2;
            y1 -= y2;
            long disSq = x1 * x1 + y1 * y1;
            long dis   = MathFP.Sqrt(disSq << MathFP.DEFAULT_PRECISION);

            return(MathFP.ToInt(dis));
        }
Exemplo n.º 4
0
        ////////////////////////////////////////////////////////////////////////////
        //--------------------------------- REVISIONS ------------------------------
        // Date       Name                 Tracking #         Description
        // ---------  -------------------  -------------      ----------------------
        // 02NOV2008  James Shen                              Initial Creation
        ////////////////////////////////////////////////////////////////////////////

        /**
         * {@inheritDoc}
         */
        public virtual Rectangle GetBounds()
        {
            long width  = GetWidth();
            long height = GetHeight();

            if (width < 0 || height < 0)
            {
                return(new Rectangle());
            }
            long x  = GetX();
            long y  = GetY();
            long x1 = MathFP.Floor(x);
            long y1 = MathFP.Floor(y);
            long x2 = MathFP.Ceil(x + width);
            long y2 = MathFP.Ceil(y + height);

            return(new Rectangle((int)x1, (int)y1,
                                 (int)(x2 - x1), (int)(y2 - y1)));
        }