Add Vec#fromPoint

This commit is contained in:
TheMode 2021-07-11 19:56:15 +02:00
parent a9e78d5583
commit 96c7fc9147

View File

@ -53,6 +53,19 @@ public final class Vec implements Point {
this(value, value, value);
}
/**
* Converts a {@link Point} into a {@link Vec}.
* Will cast if possible, or instantiate a new object.
*
* @param point the point to convert
* @return the converted vector
*/
public static @NotNull Vec fromPoint(@NotNull Point point) {
if (point instanceof Vec)
return (Vec) point;
return new Vec(point.x(), point.y(), point.z());
}
/**
* Creates a new point with coordinated depending on {@code this}.
*