# Geometry question: translating a rectangle according to a specific rule

Please take a look at the figure below. I have two line segments: a, which goes from point A to point B, and b, which goes from point B to point C. Each line defines a rectangle, which has width d and the line goes through the middle of it (along the longer edges of the rectangle). I want to find point D, given that I know the positions of point A, point B and point C and that D is at such a position, that the lower right edge of the new rectangle it forms (the green one) coincides with the right-most corner of the rectangle defined by line a.

In other words, this transformation involves rotating the line a certain degree to the left with respect to point C and then shortening it so that point B coincides with point D (or the other way around - shortening it first and then rotating it).

So the first thing I did was to calculate the position of the right-most edge of the rectangle defined by line a thinking I could somehow get the slope of the green rectangle's shorter edge and get to D, knowing that the distance between the rightmost corner to D is d/2. However, I don;t know how to get that slope; this method is probably not the correct one. Do you have any ideas how to solve that?