From 3320ab34cddcb55a3ecbfa314160bf134cf92589 Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Thu, 5 Apr 2007 20:24:47 +0000 Subject: [PATCH] We specify an Arcing path in terms of a start position and various parameters. It's useful to be able to ask the resulting path where that path ended, especially if we want to create another path starting from that new end point. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@185 ed5b42cb-e716-0410-a449-f6a68f950b19 --- .../com/threerings/media/util/ArcPath.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/media/util/ArcPath.java b/src/java/com/threerings/media/util/ArcPath.java index ad442aeb..5f01792d 100644 --- a/src/java/com/threerings/media/util/ArcPath.java +++ b/src/java/com/threerings/media/util/ArcPath.java @@ -96,7 +96,7 @@ public class ArcPath extends TimedPath int starty = (int)(_center.y + Math.round(Math.sin(_sangle) * _yradius)); - return new ArcPath(new Point (startx + x, starty + y), + return new ArcPath(new Point(startx + x, starty + y), _xradius, _yradius, _sangle, _delta, _duration, _orient); } @@ -114,6 +114,16 @@ public class ArcPath extends TimedPath _orientOffset = offset; } + /** + * Returns the position of the end of the path. + */ + public Point getEndPos () + { + return new Point( + (int)(_center.x + Math.round(Math.cos(_sangle + _delta) * _xradius)), + (int)(_center.y + Math.round(Math.sin(_sangle + _delta) * _yradius))); + } + // documentation inherited public boolean tick (Pathable pable, long timestamp) { @@ -147,7 +157,7 @@ public class ArcPath extends TimedPath // adjust it appropriately orient = DirectionUtil.rotateCW(orient, 2*_orientOffset); break; - + case FINE: orient = DirectionUtil.getFineDirection(theta); // adjust it appropriately @@ -160,14 +170,14 @@ public class ArcPath extends TimedPath pable.setOrientation(orient); modified = true; } - } - + } + // update the pathable's location if it moved if (pable.getX() != _tpos.x || pable.getY() != _tpos.y) { pable.setLocation(_tpos.x, _tpos.y); modified = true; } - + // if we completed our path, let the sprite know if (angle == _sangle + _delta) { pable.pathCompleted(timestamp);