From b58c1a3cf426764cbfd366af9cf21b683a70deda Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 15 Mar 2005 07:58:06 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/util/MathUtil.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/util/MathUtil.java b/src/java/com/threerings/media/util/MathUtil.java index 6baca5abe..55f9f8a31 100644 --- a/src/java/com/threerings/media/util/MathUtil.java +++ b/src/java/com/threerings/media/util/MathUtil.java @@ -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. */