Hi,

I am trying to replace one object with another object of a different size. If there is no rotation everything works fine. As soon as rotation is added the new object is shifted. Rotation is performed around the centre of the object. Height and width are calculated before rotation.

I can easly calculated the rotated X, Y, height and width.

double radians = firstObject.Degree * Math.PI / 180;

new1H = (int)Math.Round(Math.Abs(firstObject.Height * Math.Cos(radians)) + Math.Abs(firstObject.Width * Math.Sin(radians)) + .5);

new1W = (int)Math.Round(Math.Abs(firstObject.Width * Math.Cos(radians)) + Math.Abs(firstObject.Height * Math.Sin(radians)) + .5);

new1X = firstObject.X - (new1W - firstObject.Width) / 2;

new1Y = firstObject.Y - (new1H - firstObject.Height) / 2;

Below is what I'm starting with.

This is what I get when I do a replace. Please note how the top left corner of the new object does not match where the top left of the old object was.

Below is what I want. Please note the way the top left corner of the new object is at the same X, Y coordinates as the old object.

Any help appreciated!