# Thread: Calculate third point from 2 points and an angle

1. ## Calculate third point from 2 points and an angle

I'm having a hard time putting together a formula. I have 2 points (x0, y0) and (x1, y1) and an angle (k).
Using this information I need to calculate a third point that is k degrees from the previous 2 points.

Is it possible to do that? Thank you for your attention.

2. ## Re: Calculate third point from 2 points and an angle

Every point on the line through $(x_0, y_0)$ and your "C" satisfy that condition. Don't you have more information, like the distance from C to either of the given points?

3. ## Re: Calculate third point from 2 points and an angle

I would use linear algebra for this. Turn the two points you have into a vector:

$(x_1-x_0)\hat{i}+(y_1-y_0)\hat{j} = \begin{pmatrix}x_1-x_0 \\ y_1-y_0\end{pmatrix}$

Next, multiply by the rotational matrix:

$\begin{pmatrix}\cos k & -\sin k \\ \sin k & \cos k\end{pmatrix}$

So, you have:

\begin{align*}c & = \begin{pmatrix}x_0 \\ y_0\end{pmatrix} + \begin{pmatrix}\cos k & -\sin k \\ \sin k & \cos k\end{pmatrix}\begin{pmatrix}x_1 - x_0 \\ y_1-y_0\end{pmatrix} \\ & = \begin{pmatrix}x_0 + (x_1-x_0)\cos k-(y_1-y_0) \sin k \\ y_0 + (x_1-x_0) \sin k + (y_1-y_0)\cos k\end{pmatrix}\end{align*}

4. ## Re: Calculate third point from 2 points and an angle

That assumes that the distance from $(x_0, y_0)$ to C is the same as the distance from $(x_0, y_0)$ to $(x_1, y_1)$ which was probably what was intended but was not actually said in the first post.

5. ## Re: Calculate third point from 2 points and an angle

Originally Posted by HallsofIvy
That assumes that the distance from $(x_0, y_0)$ to C is the same as the distance from $(x_0, y_0)$ to $(x_1, y_1)$ which was probably what was intended but was not actually said in the first post.
Very true. You can multiply the rotation matrix by a sizing scalar to obtain any point along the new vector.

6. ## Re: Calculate third point from 2 points and an angle

Thanks, it is exactly what I needed. I was searchind and saw this method:
Cx=cos(θ)⋅(X1−X0)−sin(θ)⋅(Y1−Y0)+X0
Cy=sin(θ)⋅(X1−X0)+cos(θ)⋅(Y1−Y0)+Y1

The distance between P0 and P1 is the same of P0 and C.
Thanks one more time.