-3

I have some problem with math today :) Could you tell me how should I calculate $P$ angle?

img]

I know first and last point of each line. So I have:

L1 = [(10,10),(15,15)]
L2 = [(15,15),(20,8)]

But I don't have idea how calculate this angle. If I should be more specific I need to know $\cos$ of this angle. I would like to write this in Python.

Rick
  • 1,896
  • What mathematical tools are you comfortable using? Anything? Use linear algebra to describe this. Find the direction vectors for each by subtracting the startpoint from the endpoint for each, find the dot product of the results, divide by the magnitudes, and take the arcCosine. That is using the identity $\langle a,b\rangle = |a||b|\cos(\theta)$ – JMoravitz Jun 05 '20 at 12:51
  • In python, you can use the np.dot() function to get the scalar product of the two vectors. Then if you are interested in the cosine of the angle, divide by magnitudes of both vectors. – Andrew Chin Jun 05 '20 at 13:29
  • Thank you Andrew – MlodyPL Jun 06 '20 at 21:11

2 Answers2

1

What you need to use is the dot product formula which finds the angle between two vectors.It is

$a \cdot b=|a||b|\cos{\theta}$

where $\theta$ is the angle and |a| means magnitudte of vector a. You can treat both the lines as the two vectors a and b then plug it into the formula above to get the cosine of the angle.

Ty.
  • 5,434
Z.E.
  • 83
0

Find the slope of the two lines, then use the trig identity: $$\tan{\left(A+B\right)}=\frac{\tan{A}+\tan{B}}{1-\tan{A}\tan{B}}$$ Where $\tan{A}$ is the slope of one line, $\tan{B}$ is the slope of the other line, and $\tan{\left(A+B\right)}$ is the tangent of the angle between the two lines. Then use the following identity to solve for the secant of the angle: $$\tan^2{\left(A+B\right)}+1=\sec^2{\left(A+B\right)}$$ Then find cosine by taking the reciprocal of the secant.

Ty.
  • 5,434