private float GetAngle(Rectangle pRect, Point pPoint) { Point lCenter = DrawingTracker.GetCenter(pRect); float lAngle = (float)(Math.Atan2(pPoint.Y - lCenter.Y, pPoint.X - lCenter.X) * (180.0 / Math.PI)); return(ArcTrackerAdjust.RectifyAngle(lAngle)); }
/// <summary> /// get point on ellipse around pRect via specific angle. /// use x^2/a^2 + y^2/b^2 = 1 to calculate point. /// </summary> /// <param name="pRect"></param> /// <param name="pAngle"></param> /// <returns></returns> private Point GetPoint(Rectangle pRect, float pAngle) { pAngle = ArcTrackerAdjust.RectifyAngle(pAngle); Point lRet = GetCenter(pRect); double lRadians = pAngle * Math.PI / 180; int a = pRect.Width / 2; int b = pRect.Height / 2; double lTan = Math.Tan(lRadians); double lX = (a * b) / Math.Sqrt(Math.Pow(b, 2) + Math.Pow(lTan, 2) * Math.Pow(a, 2)); if (pAngle >= 90.0 && pAngle < 270.0) { lX = -lX; } double lY = lTan * lX; lRet.Offset((int)lX, (int)lY); return(lRet); }
public ArcTracker(DrawingTool pTool) : base(pTool) { Adjust = new ArcTrackerAdjust(); }