Added method to obtain a vector from two points.

Whatdya know, I already need it.
This commit is contained in:
Michael Bayne
2012-05-11 11:03:40 -07:00
parent f2e7e7da88
commit 1541c1529f
2 changed files with 14 additions and 0 deletions
+7
View File
@@ -32,6 +32,13 @@ public class Vectors
return new Vector(magnitude * Math.cos(angle), magnitude * Math.sin(angle));
}
/**
* Creates a vector from {@code from} to {@code to}.
*/
public static Vector from (IPoint from, IPoint to) {
return new Vector(to.x() - from.x(), to.y() - from.y());
}
/**
* Returns the magnitude of the specified vector.
*/
+7
View File
@@ -32,6 +32,13 @@ public class Vectors
return new Vector(magnitude * FloatMath.cos(angle), magnitude * FloatMath.sin(angle));
}
/**
* Creates a vector from {@code from} to {@code to}.
*/
public static Vector from (IPoint from, IPoint to) {
return new Vector(to.x() - from.x(), to.y() - from.y());
}
/**
* Returns the magnitude of the specified vector.
*/