How to calculate the coordinates of point C in an isosceles triangle?

597 Views Asked by At

I hope this is not a duplicate but maybe I don't know the right keywords.

In the following diagram, I know the coordinates of $A=(X_a, Y_a)$ and $B=(X_b, Y_b)$, as well as the distance $h$. What I'm looking for is the coordinates of point $C$. Point $O$ is the midpoint between $A$ and $B$.

enter image description here

I know that I can use the Pythagorean theorem in order to calculate $AC$ and $BC$, but how would I proceed?

If that helps, I need this for rotating a rectangle using python and openCV.

1

There are 1 best solutions below

4
On BEST ANSWER

You have $$\vec{A} = \left [ \begin{matrix} x_A \\ y_A \end{matrix} \right ], \quad \vec{B} = \left [ \begin{matrix} x_B \\ y_B \end{matrix} \right ]$$ Because $\vec{O}$ is halfway between $\vec{A}$ and $\vec{B}$, it is $$\vec{O} = \frac{\vec{A} + \vec{B}}{2} = \left [ \begin{matrix} \frac{x_A + x_B}{2} \\ \frac{y_A + y_B}{2} \end{matrix} \right ]$$ The unit direction vector from $\vec{A}$ to $\vec{B}$ is $\hat{U}$: $$\hat{U} = \frac{\vec{B} - \vec{A}}{\left\lVert \vec{B} - \vec{A} \right\rVert} = \left [ \begin{matrix} \frac{x_B - x_A}{\sqrt{(x_B - x_A)^2 + (y_B - y_A)^2}} \\ \frac{y_B - y_A}{\sqrt{(x_B - x_A)^2 + (y_B - y_A)^2}} \end{matrix} \right ] = \left [ \begin{matrix} x_U \\ y_U \end{matrix} \right ]$$ The other unit direction vector $\hat{V}$ is $\hat{U}$ rotated 90° degrees clockwise: $$\hat{V} = \left [ \begin{matrix} y_U \\ - x_U \end{matrix} \right ] $$ Thus, if $\vec{C}$ is at distance $h$ from $\vec{O}$ in the direction of $\hat{V}$, then $$\vec{C} = \vec{O} + h \hat{V} = \left [ \begin{matrix} \frac{x_A + x_B}{2} + h y_U \\ \frac{y_A + y_B}{2} - h x_U \end{matrix} \right ]$$