Added a version of distance that doesn't do the square root.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3407 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2005-03-15 07:58:06 +00:00
parent 2d19a0ba82
commit b58c1a3cf4
@@ -1,5 +1,5 @@
//
// $Id: MathUtil.java,v 1.12 2004/11/04 04:52:31 mdb Exp $
// $Id$
//
// Narya library - tools for developing networked games
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
@@ -40,6 +40,14 @@ public class MathUtil
return Math.min(high, Math.max(low, value));
}
/**
* Return the squared distance between the given points.
*/
public static int distanceSq (int x0, int y0, int x1, int y1)
{
return ((x1 - x0) * (x1 - x0)) + ((y1 - y0) * (y1 - y0));
}
/**
* Return the distance between the given points.
*/