Allow a Vector to be set from any XY.
I'm tempted to make add/subtract/scale take XY as well, but I'm not sure I love that. Part of the point (pardon the pun) of having Point and Vector is to use the types to prevent one from performing nonsensical operations. For example, you lerp between two vectors, lerping between a Vector and a Point would be weird; sloppy at best, most likely wrong. Adding/subtracting a point to/from a vector feels like it's in the wrong category as well, so perhaps it's best to continue to prevent that via the type system. If you really have a Point (or some other XY) that represents a vector, then I guess I'm fine with forcing you to either put it into a Vector to get the convenient math, or to pull out its x/y components manually. Then again, that also feels overly paternal. Blah.
This commit is contained in:
@@ -105,7 +105,7 @@ public class Vector extends AbstractVector
|
||||
|
||||
/** Copies the elements of another vector.
|
||||
* @return a reference to this vector, for chaining. */
|
||||
public Vector set (IVector other) {
|
||||
public Vector set (XY other) {
|
||||
return set(other.x(), other.y());
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Vector extends AbstractVector
|
||||
|
||||
/** Copies the elements of another vector.
|
||||
* @return a reference to this vector, for chaining. */
|
||||
public Vector set (IVector other) {
|
||||
public Vector set (XY other) {
|
||||
return set(other.x(), other.y());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user