Skip to content

Instantly share code, notes, and snippets.

@hueitan
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hueitan/c1f46c3c3a52a0589365 to your computer and use it in GitHub Desktop.
Save hueitan/c1f46c3c3a52a0589365 to your computer and use it in GitHub Desktop.
N = _fArgs[0]

P1 = N[0]
P2 = N[1]
P3 = N[2]

// area - check http://www.gottfriedville.net/mathtools/triarea.html
Area = Math.abs((P1[0]*(P2[1]-P3[1]) + P2[0]*(P3[1]-P1[1]) + P3[0]*(P1[1]-P2[1]))/2)

if (Area != 0) {
  return Area | 0
}

// length
X1 = Math.sqrt(Math.pow((P1[0]-P2[0]),2) + Math.pow((P1[1]-P2[1]),2)) | 0
X2 = Math.sqrt(Math.pow((P1[0]-P3[0]),2) + Math.pow((P1[1]-P3[1]),2)) | 0
X3 = Math.sqrt(Math.pow((P2[0]-P3[0]),2) + Math.pow((P2[1]-P3[1]),2)) | 0

return Math.max(X1,X2,X3)

2 points distance - check http://stackoverflow.com/a/20916980/1748884

var d = Math.sqrt( (x2-=x1)*x2 + (y2-=y1)*y2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment