Skip to content

Instantly share code, notes, and snippets.

@au5ton
Created February 3, 2016 05:24
Show Gist options
  • Save au5ton/2ea8b07835659ab21a2a to your computer and use it in GitHub Desktop.
Save au5ton/2ea8b07835659ab21a2a to your computer and use it in GitHub Desktop.
//Ported from pCalculator-classic (written in C++)
function ClassifyTriangle(a, b, c)
{
//ANGLES
var result = "";
var abResult = Math.sqrt(Math.pow(a,2)+Math.pow(b,2));
if(abResult == c)
{
result += "RIGHT";
}
else if(abResult > c)
{
result += "ACUTE";
}
else if(abResult < c)
{
result += "OBTUSE";
}
//BUFFER
result += " ";
//SIDES
if(a != b && a != c)
{
result += "SCALENE";
}
else if(a == b && a != c)
{
result += "ISOSCELES";
}
else if(a != b && a == c)
{
result += "ISOSCELES";
}
else if(a == b && a == c)
{
result += "EQUILATERAL";
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment