From d543a0574d1fee36d3ad4c8ae2a954743ea2f983 Mon Sep 17 00:00:00 2001 From: Robert Zubeck Date: Thu, 14 Feb 2008 20:49:31 +0000 Subject: [PATCH] Convenience function to make a vector out of two points. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@415 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/as/com/threerings/flash/Vector2.as | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/as/com/threerings/flash/Vector2.as b/src/as/com/threerings/flash/Vector2.as index 18d63976..199cd58e 100644 --- a/src/as/com/threerings/flash/Vector2.as +++ b/src/as/com/threerings/flash/Vector2.as @@ -44,6 +44,14 @@ public class Vector2 return new Vector2(p.x, p.y); } + /** + * Creates a new Vector2 pointing from s to t. + */ + public static function fromPoints (s :Point, t :Point) :Vector2 + { + return new Vector2(t.x - s.x, t.y - s.y); + } + /** * Creates a Vector2 of magnitude 'len' that has been rotated about the origin by 'radians'. */