A common way to do this is to find a planar perspective transformation that “warps” the rectangle into the image quadrilateral and then use its inverse to map points on the image back to the rectangle. There are software libraries that include this as standard functionality.
If you want to code this up for yourself, it’s not terribly difficult to work out the necessary mapping. Without going into the detailed derivation, a general planar perspective transformation can be represented (in homogeneous coordinates) by a matrix of the form $$
M=\pmatrix{m_{00} & m_{01} & m_{02} \\ m_{10} & m_{11} & m_{12} \\ m_{20} & m_{21} & 1},
$$ which corresponds to the mapping $$\begin{align}
x' &= {m_{00}x+m_{01}y+m_{02} \over m_{20}+m_{21}+1} \\
y' &= {m_{10}x+m_{11}y+m_{12} \over m_{20}+m_{21}+1}.
\end{align}$$ Given a set of corner-to-corner correspondences between a pair of quadrilaterals, the eight coefficients can by found by solving a system of linear equations.
If one of the quads is a rectangle aligned with the coordinate axes, this transformation can be built up in stages, which can be more convenient for implementation in software. Assuming that we have the matrix $A$ which maps from the unit square to the quadrilateral, the rectangle-to-quadrilateral transformation can be derived by composing it with suitable translation and scaling transformations: $$
M = A\cdot S\left(\frac1w,\frac1h\right)\cdot T(-x_{LL},-y_{LL}).
$$ The inverse map is then $$
M^{-1}=T(x_{LL},y_{LL})\cdot S(w,h)\cdot A^{-1} = \pmatrix{w&0&x_{LL} \\ 0&h&y_{LL} \\ 0&0&1 }\cdot A^{-1},
$$ where $(x_{LL},y_{LL})$ are the coordinates of the rectangle’s lower-left corner. Left-handed coordinate systems can be accommodated by throwing in the appropriate reflections, and skew rectangles can be dealt with by adding a rotation to the transformation cascade.
Now, it’s just a matter of finding the matrix $A$. Let the corners of the quadrilateral be given by the points $q_i'$, and map the corners of the unit square to them as follows: $$\begin{align}
(0,0)&\mapsto q_0' \\
(1,0)&\mapsto q_1' \\
(0,1)&\mapsto q_2' \\
(1,1)&\mapsto q_3'.
\end{align}$$ Solving the resulting system of equations is tedious, but straightforward. One form of the solution is as follows: $$\begin{align}
a_{00} &= a_{20}x_1'+\Delta x_{10} \\
a_{10} &= a_{20}y_1'+\Delta y_{10} \\
a_{20} &= {\omega(\Delta_{10},\Delta_{32})+\omega(\Delta_{20},\Delta_{32})-\omega(\Delta_{30},\Delta_{32}) \over \omega(\Delta_{31},\Delta_{32})} \\
a_{01} &= a_{21}x_2'+\Delta x_{20} \\
a_{11} &= a_{21}y_2'+\Delta y_{20} \\
a_{21} &= -{\omega(\Delta_{10},\Delta_{31})+\omega(\Delta_{20},\Delta_{31})-\omega(\Delta_{30},\Delta_{31}) \over \omega(\Delta_{31},\Delta_{32})} \\
a_{02} &= x_0' \\
a_{12} &= y_0', \\
\end{align}$$ where $\Delta_{ij}=q_i'-q_j'$, $\Delta x_{ij}$ and $\Delta y_{ij}$ are the corresponding coordinate deltas, and $\omega$ is the symplectic form $\omega(\mathbf u, \mathbf v) = u_xv_y-u_yv_x$. (That this looks like a lot of cross products is no coincidence—there’s a geometric interpretation of the solution as the intersection of various planes.)
Since you’re mainly interested in mapping from a quadrilateral to a rectangle, it might be more efficient, and probably more computationally stable, to compute $A^{-1}$ directly from the corner coordinates. It’s similar to the solution for the other direction, but I’ll leave that calculation to you.
$\underline{\mathrm{Introduction}}$
We assume that, by now, you have realized that this problem cannot be solved using geometry alone. As @David.k has pointed out in his comment, the equilibrium of coplanar forces and moments acting on the bar must also be taken into account. However, we only need to bother about the directions and not the magnitude of these quantities.
Now, if your knowledge of Engineering Mechanics is as good as that of mathematics, you have to have blind faith in us, when we state that three coplanar forces acting on a body in equilibrium concur, i.e. meet at a point. For instance, the bar shown in $\mathrm{Fig. 1}$ is not in equilibrium, because there is a counterclockwise moment proportional to the distance $p_x$, which pulls one of its end (i.e. $A$) downwards and pushes its other end (i.e. $B$) upwards. This moment strives to change the position of the bar by adjusting the strings until the point $P$ lands somewhere on the vertical line passing through its center of gravity. When the system attains its stability, it may look like the one shown in $\mathrm{Fig. 2}$
We are going to exploit the above-mentioned phenomenon to concoct a method to determine the length of the two strings to hang a bar of given length ($2b$) from two hooks fixed a known distance $d_1+d_2$ apart, so that the midpoint of the bar coincides with a given point in space, for instance $O$. This method works if and only if lengths $b, d_1, d_2$, and $h$ are greater than zero. The case, in which $d_1=d_2=0$, has to be analysed using common sense.
$\underline{\mathrm{Method}}$
To understand the derivation of this method, you need to polish up your knowledge of Coordinate Geometry. Without loss of generality, we assume that the midpoint $O$ of the bat lies at the origin of the Cartesian coordinate system. As shown in $\mathrm{Fig. 2}$, the two lines representing the strings have the same $y$-intercept, if their point of intersection $P$ lies on the $y$-axis, which is the vertical line passing through the CG of the bar. The only unknown in this system is $\phi$, the bar’s tilt to the horizontal - negative $x$-axis to be precise. Please note that $\phi$ is always seen as a positive quantity and. measured clockwise to avoid ambiguity. Therefore, when we get a negative angle as the answer for $\phi$, we make it positive by subtracting its absolute value from the full angle, i.e. $360^o$.
Using the points $A, B, C$, and $D$ and their coordinates depicted in the figure, we can express the equations of the strings $DA$ and $CB$ as
$$y=\space\space\space\left(\frac{h-b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_1}\right)x + h + \left(\frac{h-b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_1}\right)d_1, \tag{String $\it{DA}$}$$
$$y=-\left(\frac{h+b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_2}\right)x + h + \left(\frac{h+b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_2}\right)d_2. \tag{String $\it{CB}$}$$
When we equate the two $y$-intercepts of these lines, we get,
$$h + \left(\frac{h-b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_1}\right)d_1 = h + \left(\frac{h+b\sin\left(\phi\right)}{b\cos\left(\phi\right)–d_2}\right)d_2.$$
When we simplify this, we have,
$$\Big(h-b\sin\left(\phi\right)\Big)\Big(b\cos\left(\phi\right)–d_2\Big)d_1 = \Big(h+b\sin\left(\phi\right)\Big)\Big(b\cos\left(\phi\right)–d_1\Big)d_2.$$
After eliminating $\cos\left(\phi\right)$from the left-hand side of the above expression, we simplify it further to obtain the following equation of degree four in $\sin\left(\phi\right)$.
$$a_4\sin^4\left(\phi\right) + a_3\sin^3\left(\phi\right) + a_2\sin^2\left(\phi\right) + a_1\sin\left(\phi\right) + a_0 = 0, \quad\mathrm{where,} \tag{1}$$
$a_4 = b^2\left(d_1+d_2\right)^2,\space a_1 = -a_3 = 2hb\left(d_1^2-d_2^2\right),\space a_0 = - h^2\left(d_1-d_2\right)^2,\space$ and $\space a_2 = 4d_1^2d_2^2 - a_4 – a_0$.
To solve this equation to find the values of $\phi$, you have to use numerical methods or use a tool such as Wolfram Mathematica. This equation has either four complex roots or two complex roots and two real roots. In the former case, this problem has no ($real$) solution. In the later instance, we have two mathematically valid solutions, where one of them is always positive and the other is always negative. However, only one of them leads to a system in stable equilibrium. $\mathrm{Fig. 3}$ shows an example, where we provide both mathematically valid solutions. We hope that you can visualize in this diagram why configuration shown to the right is in neutral equilibrium and, thus, making it useless in practice.
In order to find out which of the two solutions leads to the instance of stable equilibrium, we need to differentiate between three possible scenarios depending on the size of $d_1$ and $d_2$. If $d_1 \lt d_2$, the stable equilibrious configuration arises from the positive solution. On the other hand, if $d_1 \gt d_2$, it is the negative solution that indicates the tilt of the bar in stable equilibrium,. The third scenario occurs when we have $d_1 = d_2$. In this special case, equation (1) breaks up into two equations as shown below. Please note that we have introduced a variable $d$ not shown in the diagrams such that $d = d_1 = d_2$.
$$ \sin^2\left(\phi\right) = 0 \qquad\rightarrow\qquad \phi_1=\phi_2=0^o \tag{2}$$
$$\sin^2\left(\phi\right) = \left(1 - \frac{d^2}{b^2} \right) \qquad\rightarrow\qquad \phi=\pm \sin^{-1}\left(\sqrt{1 - \frac{d^2}{b^2}}\right) \tag{3}$$
Equation (2) gives us the two solutions, type of which we are now familiar with – the bar in stable and neutral equilibrium. Unlike in the other two scenarios, the bar is horizontal in both states of equilibrium (see $\mathrm{Fig. 4}$). Furthermore, when $b \ge d$ (see $\mathrm{Fig. 5}$), as indicated by equation (3), this scenario possesses two additional stable equilibrium states. These configurations of equilibrium are in complete agreement with the laws of mechanics, because the two strings are parallel to $y$-axis and, therefore, all three line meet at infinity as required by those laws. Equation (3) does not have real solutions when $b \lt d$.
We suggest that you should work out the special case, where $b, d_1, h > 0$ and $d_2 = 0$, to test yourself the knowledge you have acquired by reading this answer. As we have already noted, the case of $d_1=d_2=0$ cannot be analysed using this method, because in this particular case we have $a_4 = a_3 = a_2 = a_1 = a_0 = 0$, i.e. equation (1) vanishes. That does not mean that there is no stable configuration when $d_1=d_2=0$. On the contrary, there is a $nice$ solution. We would like to leave it to OP to find that solution.
After choosing the value of $\phi$, which gives the configuration in the state of stable equilibrium, you can use the following equations to determine the lengths of the two strings.
$$s_1 = \sqrt{\Big(b\cos\left(\phi\right)-d_1\Big)^2 + \Big(h-b\sin\left(\phi\right)\Big)^2} \tag{String $\it{DA}$}$$
$$s_2 = \sqrt{\Big(d_2-b\cos\left(\phi\right)\Big)^2 + \Big(h+b\sin\left(\phi\right)\Big)^2} \tag{String $\it{CB}$}$$
Best Answer
Each pentagon consists of an equilateral triangle and a rhombus, see figure (and the Note at the end) To obtain a desired tiling, you can consider the length of each side equal $1.$
The center of the configuration is in $0.$ Starting with two points (here $0$ and $1$), any further point is obtained by a rotation of a point we already have. With the use of complex numbers has a rotation a simple formula $$z'-z_0=e^{i\varphi}(z-z_0),$$ where $z_0$ is ordinate of the center of the rotation, $z$ is that of the point you want to rotate, and $z'$ is the obtained image of $z.$ Complex ordinates of some points are enclosed.
Note added: there is a typo in the picture, the most right point is obtained by a clockwise rotation (negative angle), the right term is $e^{-i10\pi/18}.$