-2
$\begingroup$

What is the easiest way to determine that, given 3 coords, they DON'T form a right angled triangle?

EG, (0, 0, 0), (0, 1, 0), (1, 0, 0) - forms a right angled triangle

(0, 0, 0), (0, 1, 0), (1, 0.5, 0) - does not form a right angled triangle

$\endgroup$
0
2
$\begingroup$

3 points always form a triangle.

For a triangle with side lengths $a$, $b$, $c$, the Pythagorean theorem states that if and only if $a^2 + b^2 = c^2$ then the triangle is a right triangle.


If $a$ is the distance between points $p$ and $q$, with $p = \begin{bmatrix} p_1 \\ p_2 \\ p_3 \end{bmatrix}$, and $q = \begin{bmatrix} q_1 \\ q_2 \\ q_3 \end{bmatrix}$,

then $$a = |P - Q| = \sqrt{(p_1 - q_1)^2 + (p_2 - q_2)^2 + (p_3 - q_3)^2}$$

so

$$a^2 = (p_1 - q_1)^2 + (p_2 - q_2)^2 + (p_3 - q_3)^2$$

$\endgroup$
4
  • $\begingroup$ so is that for any sides, or does c have to be the hypotenuse $\endgroup$ – Ogen Feb 24 '15 at 1:48
  • 1
    $\begingroup$ $c$ has to be the longest for the relation to hold at all. $\endgroup$ – DanielV Feb 24 '15 at 1:53
  • $\begingroup$ what about when the point are laying on the same line? This test will lead to a false positive $\endgroup$ – Alessandro Teruzzi May 20 '20 at 13:20
  • $\begingroup$ calculating the dot product will cover this case as well $\endgroup$ – Alessandro Teruzzi May 20 '20 at 13:28
1
$\begingroup$

Draw it and test the angle that seems likely taking the dot product of the two vectors corresponding to the sides of that vertex. You can test all three if you don't want to draw.


Alternatively calculate the side lengths, if $c$ is the largest and $c^2=a^2+b^2$ it is a right triangle, otherwise it isn't.

$\endgroup$
1
$\begingroup$

For this, I believe it is best to calculate the length of every side before using Pythagoras theorem, hope this helps!

$\endgroup$
2

Not the answer you're looking for? Browse other questions tagged or ask your own question.