From 0bd239c74c898f5db3fe4919487a1ec7ee851a62 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 15 Mar 2005 07:58:28 +0000 Subject: [PATCH] Added a version of getDirection() that works directly with doubles. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3408 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/util/DirectionUtil.java | 17 +++++++++++++++-- .../threerings/util/unsafe/Linux/libunsafe.so | Bin 8252 -> 8252 bytes 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/util/DirectionUtil.java b/src/java/com/threerings/util/DirectionUtil.java index 02ae5c0e7..79b23b922 100644 --- a/src/java/com/threerings/util/DirectionUtil.java +++ b/src/java/com/threerings/util/DirectionUtil.java @@ -1,5 +1,5 @@ // -// $Id: DirectionUtil.java,v 1.11 2004/08/27 02:20:36 mdb Exp $ +// $Id$ // // Narya library - tools for developing networked games // Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved @@ -143,7 +143,7 @@ public class DirectionUtil implements DirectionCodes */ public static int getDirection (Point a, Point b) { - return getDirection(a.x, a.y, b.x, b.y); + return getDirection(a.getX(), a.getY(), b.getX(), b.getY()); } /** @@ -159,6 +159,19 @@ public class DirectionUtil implements DirectionCodes return getDirection(Math.atan2(by-ay, bx-ax)); } + /** + * Returns which of the eight compass directions that point + * b lies in from point a as one of the + * {@link DirectionCodes} direction constants. Note: that the + * coordinates supplied are assumed to be logical (screen) rather than + * cartesian coordinates and NORTH is considered to point + * toward the top of the screen. + */ + public static int getDirection (double ax, double ay, double bx, double by) + { + return getDirection(Math.atan2(by-ay, bx-ax)); + } + /** * Returns which of the eight compass directions is associated with * the specified angle theta. Note: that the angle supplied diff --git a/src/java/com/threerings/util/unsafe/Linux/libunsafe.so b/src/java/com/threerings/util/unsafe/Linux/libunsafe.so index 8ab8af64e795d906e0087781cc49a90e61e3ac1c..671df8a7e831bc3c3917c6a601c815c803d0136b 100755 GIT binary patch delta 30 bcmdnvu*YG;ZXQO9$q#u{kjc$jyh6eNvepU~ delta 30 bcmdnvu*YG;ZXQOn$q#u{kjc$jyh6eNvUUm(