/// <summary> /// Converts a rectangle into an equivalent polygon /// </summary> /// <param name="r"></param> /// <returns></returns> public static Polygon GetFromRectangle(Rectangle r) { Polygon tmp = new Polygon(UNIT_SQUARE(), LocationManager.getVectorFromPoint(r.Center), 0); tmp.Scale(r.Width, r.Height); return(tmp); }
/// <summary> /// Converts a line into a polygonal approximation, defined as an infinitely thin rectangle /// </summary> /// <param name="A"></param> /// <param name="B"></param> /// <returns></returns> public static Polygon GetFromLine(Vector2 A, Vector2 B) { float ang = LocationManager.getRotation(A, B); float dist = LocationManager.getDistance(A, B); Polygon tmp = new Polygon(UNIT_SQUARE(), LocationManager.moveByRotation(A, dist / 2, ang),ang ); tmp.Scale(dist, 0); return tmp; }