//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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)); }
//////////////////////////////////////////////////////////////////////////// //--------------------------------- 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)); }