Added method to obtain a vector from two points.
Whatdya know, I already need it.
This commit is contained in:
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user