I have to use a propriertary graphics-engine for drawing a line. I can rotate the whole drawing by its origin point (P1). What I want, is to rotate it around its center point(M). So basically that it looks like L_correct instead of L_wrong.
I think, it should be possible to correct it, by moving it from P1 to P2. But I cannot figure out what formula could be used, to determine the distance. It must probably involve the angle, width and height...
So basically my question is, if there is a function to determine x2 and y2 based on my available data?

Let's assume you have a primitive method that rotates a drawing by any given angle
phi. What you want is to use that primitive to rotate a drawingDaround a pointMinstead. Here is a sketch of how to proceed.Translate you drawing by
-M, i.e., apply the transformationT(P) = P - Mto all pointsPin your drawing. LetT(D)be the translation ofD.Now use the primitive to rotate
T(D)by the desired anglephi. LetR(T(D))be the result.Now translate the previous result by
Mand get the rotated drawing. In other words, use the transformationT'(P) = P + M.Note that in step 1 above
Mis mapped to the origin0, where the rotation primitive is known to work. After rotating in step 2, the opposite translation of step 3 puts back the drawing on its original location as this time0is mapped toM.