Calculate y2 given x1, y1, x2 and angle

288 Views Asked by At

I'm a bit confused and haven't used trigonometry in years, in the following image I have the x1, y1 and x2 coordinates and I need to calculate the y2 value. Given the angle in degrees I first convert it in radians and then use tangent to calculate the y2 value, however the result is not the one expected.

This is what I did:

x1 = 91
y1 = 32
x2 = 100
angle = 19

angleRad = angle * π / 180
y2 = y1 + (x2 - x1) * tan(angleRad);

Any suggestion to where I may be wrong? enter image description here

1

There are 1 best solutions below

0
On

You need to start from the definition: \begin{align} \tan(19°) &=\frac{\textrm{Length of side opposite to the angle}}{\textrm{Length of side adjacent to the angle}}\\ &=\frac{x_{2}-x_{1}}{y_{2}-y_{1}} \end{align} and there you can identify your mistake. It doesn't matter if you use degrees or radians as long as you use the appropiate version of $\tan(\theta)$ in your machine or app for calculation.