I want to determine whether the measure of angle Q is greater than 90 degrees.
-
3$\begingroup$ it's less than 90 degrees ;-) $\endgroup$– JPiMar 6, 2014 at 12:34
-
1$\begingroup$ Suggestion - use the cosine rule $\endgroup$– Mark BennetMar 6, 2014 at 12:35
-
$\begingroup$ 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. $\endgroup$– DonAntonioMar 6, 2014 at 12:37
3 Answers
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$.
-
-
$\begingroup$ 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. $\endgroup$– 7raiden7Mar 6, 2014 at 12:43