diff --git a/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index eecdcc6cc..fe1709fa4 100644 --- a/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -109,6 +109,7 @@ public class AffineTransform implements Transform { // =================================================================== // accessors + @Override public boolean isIdentity() { if (m00 != 1) return false; diff --git a/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java b/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java index 84b1a474b..eab410b99 100644 --- a/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java +++ b/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java @@ -54,6 +54,17 @@ public class CombinedTransform implements Transform { this(transforms.toArray(new Transform[checkNotNull(transforms).size()])); } + @Override + public boolean isIdentity() { + for (Transform transform : transforms) { + if (!transform.isIdentity()) { + return false; + } + } + + return true; + } + @Override public Vector apply(Vector vector) { for (Transform transform : transforms) { diff --git a/src/main/java/com/sk89q/worldedit/math/transform/Identity.java b/src/main/java/com/sk89q/worldedit/math/transform/Identity.java index a5f22038d..cac70ba36 100644 --- a/src/main/java/com/sk89q/worldedit/math/transform/Identity.java +++ b/src/main/java/com/sk89q/worldedit/math/transform/Identity.java @@ -26,6 +26,11 @@ import com.sk89q.worldedit.Vector; */ public class Identity implements Transform { + @Override + public boolean isIdentity() { + return true; + } + @Override public Vector apply(Vector vector) { return vector; diff --git a/src/main/java/com/sk89q/worldedit/math/transform/Transform.java b/src/main/java/com/sk89q/worldedit/math/transform/Transform.java index cb3109879..b8df8bcbd 100644 --- a/src/main/java/com/sk89q/worldedit/math/transform/Transform.java +++ b/src/main/java/com/sk89q/worldedit/math/transform/Transform.java @@ -26,6 +26,15 @@ import com.sk89q.worldedit.Vector; */ public interface Transform { + /** + * Return whether this transform is an identity. + * + *
If it is not known, then {@code false} must be returned.
+ * + * @return true if identity + */ + boolean isIdentity(); + /** * Returns the result of applying the function to the input. *