[Math] Check angle between two lines greater than 90

geometry

enter image description here

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

Best Answer

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).

Related Question