'How to change the position of 2nd rectangle when 1st rectangle is moved?

I'm drawing 2 rectangles in emgu/c# & I know their positions in the Image. I want to move the 2nd rectangle when the 1st is moved, while keeping the distance between them the same. What is the formulae/calculations to do this?

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source