Created
February 3, 2016 05:24
-
-
Save au5ton/2ea8b07835659ab21a2a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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