in the above image I have shown two rectangles
Try using this:
rectangelOne.x = rectangelTwo.x + rectangelTwo.width / 2;
rectangelOne.y = rectangelTwo.y + rectangleTwo.height / 2;
if your rectangleOne's pivot is correctly it should center automatically, otherwhise add this:
rectangleOne.x -= rectangleOne.width / 2;
rectangleTwo.y -= rectangleOne.height / 2;
hope this helps.