# Get the cosine value of a angle between two lines?

I want to find the cosine value of the Q angle

• Where are you having problem ? Commented Mar 15, 2014 at 7:17
• I don't know how to do this Commented Mar 15, 2014 at 7:19

$$cos(\theta) = \frac{a \cdot b}{|a||b|}$$

$a = (x_1-x_3)i+(y_1-y_3)j$

$b = (x_2-x_3)i+(y_2-y_3)j$

• what is mean by i and j ? Commented Mar 15, 2014 at 7:22

Although it is not related to vectors, a way of solving this problem is to use the Law of Cosines (as mentioned in previous posts), which states that, in a triangle with sides a, b, c :

$\ c^2 = a^2 - b^2 - 2ab\cos(C)$

where C is the angle of the triangle opposite side c.

In the diagram above, construct a third segment from (x1, y1) to (x2, y2).

Then, calculate the lengths of each of the sides of the resulting triangle using the distance formula for two points on a Cartesian plane This formula is derived from the Pythagorean theorem.

After you have calculated the respective lengths of each side of the triangle, then use the Law of Cosines relationship to solve for the cosine of the angle Q.

(Note: relabel angle Q as angle C and define the segment we have constructed opposite angle Q to be side c, and proceed from there)

You can use formula for dot product: $$u \dot v = \|u\| \|v\| \cos{\theta}$$ where $\theta$ is angle between vectors $u$ and $v$.

By picking $u =(x_2-x_3,y_2-x_3)$, $v = (x_1-x_3,y_1-x_3)$. You get cosine of that angle with: $$\cos{Q} = \frac{ u \dot v}{\|u\| \|v\|}$$

• what is mean by v˙ and ∥u∥ ? Commented Mar 15, 2014 at 7:24
• It is norm of $u$. $\|(x,y)\| = \sqrt{x^2+y^2}$.
– tom
Commented Mar 15, 2014 at 7:26

Hint: Let $A = (x_1, y_1)$, and $B = (x_2, y_2)$, and $C = (x_3, y_3)$. Use Pythagorean theorem to find $AB$, $BC$, and $CA$. Then use law of cosine in a triangle to find $\cos C$.