# Check angle between two lines greater than 90 ?

I want to determine whether the measure of angle Q is greater than 90 degrees.

• it's less than 90 degrees ;-)
– JPi
Commented Mar 6, 2014 at 12:34
• Suggestion - use the cosine rule Commented Mar 6, 2014 at 12:35
• If the lines are not perpendicular, then there always be an angle greater than $\;90^\circ\;$ and one less than that between them...One way to avoid this double result is to look at the inner prodcut definition of the cosine when we decide what vectors to take. Commented Mar 6, 2014 at 12:37

Calculate as follows (in C# or any similar language):

 ux = x2 - x1  ;  uy = y2 - y1;   // u = (ux,uy) = vector from p1 to p2
vx = x3 - x1  ;  vy = y3 - y1;   // v = (vx,vy) = vector from p1 to p3
d = ux*vx + uy*vy;               // Dot product of u and v


So, the number $d$ is the dot product of the vectors $\mathbf{u} =\mathbf{p}_2 - \mathbf{p}_1$ and $\mathbf{v} = \mathbf{p}_3 - \mathbf{p}_1$. If $d<0$, then the angle between the vectors $\mathbf{u}$ and $\mathbf{v}$ is greater than 90 degrees. If you actually want to find the angle, it's a bit more work (but that's not what you asked).

Form the vectors (x3 - x1, y3 - y1) and (x2 - x1, y2 - y1) and take the dot product. The dot product, from there you can get cosine of the angle between the vectors.

Why do not trying: $$\cos(Q),$$ if it is greater than $0$ the angle is between $0$ and $\pi/2$, otherwise it is between $\pi/2$ and $\pi$.

• What about tan(Q) ? Commented Mar 6, 2014 at 12:38
• You can use it as well, but if the angle is exactly $\pi/2$ you have a not defined $\tan(\pi/2)$. If you're sure a priori that the angle will not be $\pi/2$ it is equivalent to use bot cosine and tangent functions. Commented Mar 6, 2014 at 12:43