I am trying to write a programming algorithm to find two points on a trapezoid. The trapezoid could be rotated in any direction, and $h_1$, $h_2$, and $h_3$ could be any length. See attached mockup:
-
What are $x$ and $y$? Are $(a_x,a_y)$ coordinates of $a$? – John Wayland Bales Feb 20 '17 at 05:26
-
Yes. Sorry, I haven't done work like this in 20 years! – patrickkidd Feb 20 '17 at 05:38
-
Does the line marked $h_3$ connect the midpoints of the lines $ab$ and $cd$? – Joffan Feb 20 '17 at 06:30
-
Yes. the lines h[1,2,3] are just there for reference to show that it's a trapezoid – patrickkidd Feb 20 '17 at 06:40
1 Answers
There are actually two solutions for $c$ and $d$ depending upon which normal vector you take to the vector $\mathbf{u}=\left\langle a_x-b_x,a_y-b_y \right\rangle$.
$\mathbf{u}_\perp=\pm\left\langle a_y-b_y,b_x-a_x\right\rangle$. You may check that the dot product $\mathbf{u}\cdot \mathbf{u}_\perp=0$.
Then $\mathbf{v}=\left\langle \dfrac{a_x+b_x}{2},\dfrac{a_y+b_y}{2}\right\rangle$ is the vector midpoint of the segment from $b$ to $a$, so the vector midpoint of segment $cd$ is $\mathbf{w}=\left(\mathbf{v}+\dfrac{\mathbf{u}_\perp}{\vert\mathbf{u}_\perp\vert}\cdot h_3\right)$ where $\vert\mathbf{u}_\perp\vert=\vert\mathbf{u}\vert=h_1$,
Then, as vectors $\mathbf{c}=\left\langle c_x,c_y\right\rangle=\mathbf{w}+\dfrac{\mathbf{u}h_2}{2\vert \mathbf{u}\vert}$ and $\mathbf{c}=\left\langle d_x,d_y\right\rangle=\mathbf{w}-\dfrac{\mathbf{u}h_2}{2\vert \mathbf{u}\vert}$
- 21,814

