diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BitMath.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BitMath.java index 46fa66e73..8b6747696 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BitMath.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BitMath.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java index f2b4dc967..2b6d739b8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector2.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; @@ -37,8 +37,10 @@ public class BlockVector2 { * A comparator for BlockVector2ds that orders the vectors by rows, with x as the * column and z as the row. * + *

* For example, if x is the horizontal axis and z is the vertical axis, it * sorts like so: + *

* *
      * 0123
@@ -67,14 +69,18 @@ public class BlockVector2 {
                     return ONE;
                 }
                 break;
+            default:
+                break;
         }
         */
         return new BlockVector2(x, z);
     }
 
-    protected int x, z;
+    protected int x;
+    protected int z;
 
-    protected BlockVector2(){}
+    protected BlockVector2(){
+    }
 
     /**
      * Construct an instance.
@@ -221,7 +227,8 @@ public class BlockVector2 {
      * @return a new vector
      */
     public BlockVector2 add(BlockVector2... others) {
-        int newX = x, newZ = z;
+        int newX = x;
+        int newZ = z;
 
         for (BlockVector2 other : others) {
             newX += other.x;
@@ -262,7 +269,8 @@ public class BlockVector2 {
      * @return a new vector
      */
     public BlockVector2 subtract(BlockVector2... others) {
-        int newX = x, newZ = z;
+        int newX = x;
+        int newZ = z;
 
         for (BlockVector2 other : others) {
             newX -= other.x;
@@ -300,7 +308,8 @@ public class BlockVector2 {
      * @return a new vector
      */
     public BlockVector2 multiply(BlockVector2... others) {
-        int newX = x, newZ = z;
+        int newX = x;
+        int newZ = z;
 
         for (BlockVector2 other : others) {
             newX *= other.x;
@@ -371,6 +380,7 @@ public class BlockVector2 {
     public BlockVector2 shr(int n) {
         return shr(n, n);
     }
+
     /**
      * Get the length of the vector.
      *
@@ -520,8 +530,8 @@ public class BlockVector2 {
      */
     public BlockVector2 getMinimum(BlockVector2 v2) {
         return new BlockVector2(
-                Math.min(x, v2.x),
-                Math.min(z, v2.z)
+            Math.min(x, v2.x),
+            Math.min(z, v2.z)
         );
     }
 
@@ -533,8 +543,8 @@ public class BlockVector2 {
      */
     public BlockVector2 getMaximum(BlockVector2 v2) {
         return new BlockVector2(
-                Math.max(x, v2.x),
-                Math.max(z, v2.z)
+            Math.max(x, v2.x),
+            Math.max(z, v2.z)
         );
     }
 
diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java
index 1023ebfc6..6656bf67a 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3.java
@@ -3,18 +3,18 @@
  * Copyright (C) sk89q 
  * Copyright (C) WorldEdit team and contributors
  *
- * This program is free software: you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as published by the
- * Free Software Foundation, either version 3 of the License, or
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
  *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
- * for more details.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see .
  */
 
 package com.sk89q.worldedit.math;
@@ -67,6 +67,8 @@ public abstract class BlockVector3 {
                     return ONE;
                 }
                 break;
+            default:
+                break;
         }
         */
         return new BlockVector3Imp(x, y, z);
@@ -80,9 +82,9 @@ public abstract class BlockVector3 {
     }
 
     public static boolean isLongPackable(BlockVector3 location) {
-        return isHorizontallyInBounds(location.getX()) &&
-            isHorizontallyInBounds(location.getZ()) &&
-            0 <= location.getY() && location.getY() <= WORLD_Y_MAX;
+        return isHorizontallyInBounds(location.getX())
+            && isHorizontallyInBounds(location.getZ())
+            && 0 <= location.getY() && location.getY() <= WORLD_Y_MAX;
     }
 
     public static void checkLongPackable(BlockVector3 location) {
@@ -110,6 +112,7 @@ public abstract class BlockVector3 {
      *
      * 

* Useful for sorting by chunk block storage order. + *

*/ public static Comparator sortByCoordsYzx() { return YzxOrderComparator.YZX_ORDER; @@ -125,7 +128,7 @@ public abstract class BlockVector3 { public long toLongPackedForm() { checkLongPackable(this); - return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & (long) BITS_12) << (26 + 26))); + return (getX() & BITS_26) | ((getZ() & BITS_26) << 26) | (((getY() & BITS_12) << (26 + 26))); } public MutableBlockVector3 mutX(double x) { @@ -264,7 +267,9 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 add(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = getX(); + int newY = getY(); + int newZ = getZ(); for (BlockVector3 other : others) { newX += other.getX(); @@ -307,7 +312,9 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 subtract(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = getX(); + int newY = getY(); + int newZ = getZ(); for (BlockVector3 other : others) { newX -= other.getX(); @@ -347,7 +354,9 @@ public abstract class BlockVector3 { * @return a new vector */ public BlockVector3 multiply(BlockVector3... others) { - int newX = getX(), newY = getY(), newZ = getZ(); + int newX = getX(); + int newY = getY(); + int newZ = getZ(); for (BlockVector3 other : others) { newX *= other.getX(); @@ -766,8 +775,7 @@ public abstract class BlockVector3 { } public final boolean equals(BlockVector3 other) { - return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this - .getZ(); + return other.getX() == this.getX() && other.getY() == this.getY() && other.getZ() == this.getZ(); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java index 025c1beed..ea98727ce 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/BlockVector3Imp.java @@ -38,7 +38,9 @@ public final class BlockVector3Imp extends BlockVector3 { return new BlockVector3Imp(x, y, z); } - private final int x, y, z; + private final int x; + private final int y; + private final int z; /** * Construct an instance. diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java index bb8541cb2..897baad39 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MathUtils.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; @@ -63,14 +63,16 @@ public final class MathUtils { dInt += 360; } switch (dInt) { - case 0: - return 1.0; - case 90: - return 0.0; - case 180: - return -1.0; - case 270: - return 0.0; + case 0: + return 1.0; + case 90: + return 0.0; + case 180: + return -1.0; + case 270: + return 0.0; + default: + break; } } return Math.cos(Math.toRadians(degrees)); @@ -92,14 +94,16 @@ public final class MathUtils { dInt += 360; } switch (dInt) { - case 0: - return 0.0; - case 90: - return 1.0; - case 180: - return 0.0; - case 270: - return -1.0; + case 0: + return 0.0; + case 90: + return 1.0; + case 180: + return 0.0; + case 270: + return -1.0; + default: + break; } } return Math.sin(Math.toRadians(degrees)); @@ -109,7 +113,9 @@ public final class MathUtils { * Returns the rounded double of the given value, rounding to the * nearest integer value away from zero on ties. * + *

* This behavior is the same as {@link java.math.RoundingMode#HALF_UP}. + *

* * @param value the value * @return the rounded value diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java index 4aaadd81f..1f9b71bc9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector2.java @@ -8,7 +8,8 @@ public class MutableBlockVector2 extends BlockVector2 { return MUTABLE_CACHE.get().setComponents(x, z); } - public MutableBlockVector2() {} + public MutableBlockVector2() { + } public MutableBlockVector2(int x, int z) { super(x, z); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java index cbee3feb9..1304d9625 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableBlockVector3.java @@ -16,7 +16,8 @@ public class MutableBlockVector3 extends BlockVector3 { return FaweCache.IMP.MUTABLE_BLOCKVECTOR3.get().setComponents(x, y, z); } - public MutableBlockVector3() {} + public MutableBlockVector3() { + } public MutableBlockVector3(BlockVector3 other) { this(other.getX(), other.getY(), other.getZ()); @@ -26,7 +27,9 @@ public class MutableBlockVector3 extends BlockVector3 { return setComponents(other.getBlockX(), other.getBlockY(), other.getBlockZ()); } - private int x,y,z; + private int x; + private int y; + private int z; public MutableBlockVector3(int x, int y, int z) { this.x = x; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java index 4c38e9ea1..5454eb88e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/MutableVector3.java @@ -4,7 +4,9 @@ import com.boydti.fawe.FaweCache; public class MutableVector3 extends Vector3 { - private double x, y, z; + private double x; + private double y; + private double z; public MutableVector3() { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedChunkComparator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedChunkComparator.java index d6d2d89d6..09d0aaf4e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedChunkComparator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedChunkComparator.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedComparator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedComparator.java index ed715d703..8bfb1aff5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedComparator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/RegionOptimizedComparator.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java index 06143a925..3eabbcf40 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector2.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; @@ -44,11 +44,14 @@ public final class Vector2 { return ONE; } break; + default: + break; } return new Vector2(x, z); } - private final double x, z; + private final double x; + private final double z; /** * Construct an instance. @@ -128,7 +131,8 @@ public final class Vector2 { * @return a new vector */ public Vector2 add(Vector2... others) { - double newX = x, newZ = z; + double newX = x; + double newZ = z; for (Vector2 other : others) { newX += other.x; @@ -169,7 +173,8 @@ public final class Vector2 { * @return a new vector */ public Vector2 subtract(Vector2... others) { - double newX = x, newZ = z; + double newX = x; + double newZ = z; for (Vector2 other : others) { newX -= other.x; @@ -207,7 +212,8 @@ public final class Vector2 { * @return a new vector */ public Vector2 multiply(Vector2... others) { - double newX = x, newZ = z; + double newX = x; + double newZ = z; for (Vector2 other : others) { newX *= other.x; @@ -418,7 +424,7 @@ public final class Vector2 { Math.max(z, v2.z) ); } - + public static BlockVector2 toBlockPoint(double x, double z) { return BlockVector2.at(x, z); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java index ff3461e0f..11ef929c3 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math; @@ -54,6 +54,8 @@ public abstract class Vector3 { return ONE; } break; + default: + break; } */ return new Vector3Impl(x, y, z); @@ -75,6 +77,7 @@ public abstract class Vector3 { * *

* Useful for sorting by chunk block storage order. + *

*/ public static Comparator sortByCoordsYzx() { return YzxOrderComparator.YZX_ORDER; @@ -209,7 +212,9 @@ public abstract class Vector3 { * @return a new vector */ public Vector3 add(Vector3... others) { - double newX = getX(), newY = getY(), newZ = getZ(); + double newX = getX(); + double newY = getY(); + double newZ = getZ(); for (Vector3 other : others) { newX += other.getX(); @@ -252,7 +257,9 @@ public abstract class Vector3 { * @return a new vector */ public Vector3 subtract(Vector3... others) { - double newX = getX(), newY = getY(), newZ = getZ(); + double newX = getX(); + double newY = getY(); + double newZ = getZ(); for (Vector3 other : others) { newX -= other.getX(); @@ -292,7 +299,9 @@ public abstract class Vector3 { * @return a new vector */ public Vector3 multiply(Vector3... others) { - double newX = getX(), newY = getY(), newZ = getZ(); + double newX = getX(); + double newY = getY(); + double newZ = getZ(); for (Vector3 other : others) { newX *= other.getX(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3Impl.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3Impl.java index d2e81c185..7c1068417 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3Impl.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/Vector3Impl.java @@ -1,7 +1,9 @@ package com.sk89q.worldedit.math; public class Vector3Impl extends Vector3 { - private final double x,y,z; + private final double x; + private final double y; + private final double z; public Vector3Impl(double x, double y, double z) { this.x = x; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java index bb38201d2..31dec0cda 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.convolution; @@ -25,8 +25,8 @@ package com.sk89q.worldedit.math.convolution; public class GaussianKernel extends Kernel { /** - * Constructor of the kernel - * + * Constructor of the kernel. + * * @param radius the resulting diameter will be radius * 2 + 1 * @param sigma controls 'flatness' */ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index ee9a4645a..c93fe5d58 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.convolution; @@ -46,14 +46,14 @@ public class HeightMap { private final boolean layers; private int[] data; private boolean[] invalid; - private int width; - private int height; + private final int width; + private final int height; - private Region region; - private EditSession session; + private final Region region; + private final EditSession session; /** - * Constructs the HeightMap + * Constructs the HeightMap. * * @param session an edit session * @param region the region @@ -106,10 +106,11 @@ public class HeightMap { int yTmp = 255; for (int z = 0; z < height; ++z) { for (int x = 0; x < width; ++x, index++) { - if (mask != null) + if (mask != null) { yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE, mask); - else + } else { yTmp = session.getNearestSurfaceTerrainBlock(x + minX, z + minZ, yTmp, minY, maxY, Integer.MIN_VALUE, Integer.MAX_VALUE); + } switch (yTmp) { case Integer.MIN_VALUE: yTmp = minY; @@ -145,8 +146,8 @@ public class HeightMap { * @param filter the filter * @param iterations the number of iterations * @return number of blocks affected + * @throws MaxChangedBlocksException if the maximum block change limit is exceeded */ - public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException { checkNotNull(filter); @@ -182,7 +183,9 @@ public class HeightMap { for (int z = 0; z < height; ++z) { int zr = z + originZ; for (int x = 0; x < width; ++x) { - if (this.invalid != null && this.invalid[index]) continue; + if (this.invalid != null && this.invalid[index]) { + continue; + } int curHeight = this.data[index]; //Clamp newHeight within the selection area @@ -204,7 +207,9 @@ public class HeightMap { // Grow -- start from 1 below top replacing airblocks for (int setY = newBlock - 1, getY = curBlock; setY >= curBlock; --setY, getY--) { BlockStateHolder get = session.getBlock(xr, getY, zr); - if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get; + if (get != BlockTypes.AIR.getDefaultState()) { + tmpBlock = get; + } session.setBlock(xr, setY, zr, tmpBlock); ++blocksChanged; } @@ -244,17 +249,18 @@ public class HeightMap { } /** - * Apply a raw heightmap to the region + * Apply a raw heightmap to the region. * * @param data the data * @return number of blocks affected + * @throws MaxChangedBlocksException if the maximum block change limit is exceeded */ - public int apply(int[] data) throws MaxChangedBlocksException { checkNotNull(data); BlockVector3 minY = region.getMinimumPoint(); int originX = minY.getBlockX(); + int originY = minY.getBlockY(); int originZ = minY.getBlockZ(); int maxY = region.getMaximumPoint().getBlockY(); @@ -268,7 +274,9 @@ public class HeightMap { for (int z = 0; z < height; ++z) { int zr = z + originZ; for (int x = 0; x < width; ++x, index++) { - if (this.invalid != null && this.invalid[index]) continue; + if (this.invalid != null && this.invalid[index]) { + continue; + } int curHeight = this.data[index]; @@ -293,7 +301,9 @@ public class HeightMap { } else { get = BlockTypes.AIR.getDefaultState(); } - if (get != BlockTypes.AIR.getDefaultState()) tmpBlock = get; + if (get != BlockTypes.AIR.getDefaultState()) { + tmpBlock = get; + } session.setBlock(xr, setY, zr, tmpBlock); ++blocksChanged; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java index f58899fb4..73126c34f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.convolution; @@ -32,7 +32,7 @@ public class HeightMapFilter { /** * Construct the HeightMapFilter object. - * + * * @param kernel the kernel */ public HeightMapFilter(Kernel kernel) { @@ -42,7 +42,7 @@ public class HeightMapFilter { /** * Construct the HeightMapFilter object. - * + * * @param kernelWidth the width * @param kernelHeight the height * @param kernelData the data @@ -53,15 +53,15 @@ public class HeightMapFilter { } /** - * @return the kernel + * Get the kernel. */ public Kernel getKernel() { return kernel; } /** - * Set Kernel - * + * Set the kernel. + * * @param kernel the kernel */ public void setKernel(Kernel kernel) { @@ -71,7 +71,7 @@ public class HeightMapFilter { } /** - * Filter with a 2D kernel + * Filter with a 2D kernel. * * @param inData the data * @param width the width @@ -107,7 +107,9 @@ public class HeightMapFilter { int matrixOffset = ky * kw; for (int kx = 0; kx < kw; ++kx) { float f = matrix[matrixOffset + kx]; - if (f == 0) continue; + if (f == 0) { + continue; + } int offsetX = x + kx - kox; // Clamp coordinates inside data diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/Kernel.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/Kernel.java index efc051b63..7e04e6667 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/Kernel.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/Kernel.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.convolution; @@ -27,11 +27,11 @@ package com.sk89q.worldedit.math.convolution; */ public class Kernel { - private int width; - private int height; - private int xOrigin; - private int yOrigin; - private float[] data; + private final int width; + private final int height; + private final int xOrigin; + private final int yOrigin; + private final float[] data; public Kernel(int width, int height, float[] data) { this.width = width; @@ -72,4 +72,4 @@ public class Kernel { return data; } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java index 1de8dec57..386b3ff0d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java @@ -3,24 +3,26 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.convolution; +import java.util.Arrays; + /** - * A linear Kernel generator (all cells weight the same) + * A linear Kernel generator (all cells weigh the same). */ public class LinearKernel extends Kernel { @@ -32,7 +34,7 @@ public class LinearKernel extends Kernel { int diameter = radius * 2 + 1; float[] data = new float[diameter * diameter]; - for (int i = 0; i < data.length; data[i++] = 1.0f / data.length); + Arrays.fill(data, 1.0f / data.length); return data; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java index 13bc259ba..ae14589c7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/geom/Polygons.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.geom; @@ -31,19 +31,18 @@ import java.util.List; public final class Polygons { private Polygons() { - } /** * Calculates the polygon shape of a cylinder which can then be used for e.g. intersection detection. - * + * * @param center the center point of the cylinder * @param radius the radius of the cylinder * @param maxPoints max points to be used for the calculation * @return a list of {@link BlockVector2} which resemble the shape as a polygon */ public static List polygonizeCylinder(BlockVector2 center, Vector2 radius, int maxPoints) { - int nPoints = (int) Math.ceil(Math.PI*radius.length()); + int nPoints = (int) Math.ceil(Math.PI * radius.length()); // These strange semantics for maxPoints are copied from the selectSecondary method. if (maxPoints >= 0 && nPoints >= maxPoints) { @@ -60,5 +59,5 @@ public final class Polygons { return points; } - + } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java index 28ce2c492..7acc25fd1 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // $Id$ @@ -26,7 +26,7 @@ import com.sk89q.worldedit.math.Vector3; import java.util.List; /** - * Represents an arbitrary function in ℝ → ℝ3 + * Represents an arbitrary function in ℝ → ℝ3. */ public interface Interpolation { @@ -39,7 +39,7 @@ public interface Interpolation { void setNodes(List nodes); /** - * Gets the result of f(position) + * Gets the result of f(position). * * @param position the position to interpolate * @return the result diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index b7dac41aa..b4ae79cea 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // $Id$ @@ -43,10 +43,10 @@ public class KochanekBartelsInterpolation implements Interpolation { private Vector3[] coeffC; private Vector3[] coeffD; private double scaling; - private MutableBlockVector3 mutable = new MutableBlockVector3(); + private final MutableBlockVector3 mutable = new MutableBlockVector3(); public KochanekBartelsInterpolation() { - setNodes(Collections.emptyList()); + setNodes(Collections.emptyList()); } @Override @@ -64,8 +64,9 @@ public class KochanekBartelsInterpolation implements Interpolation { coeffC = new Vector3[nNodes]; coeffD = new Vector3[nNodes]; - if (nNodes == 0) + if (nNodes == 0) { return; + } Node nodeB = nodes.get(0); double tensionB = nodeB.getTension(); @@ -84,14 +85,14 @@ public class KochanekBartelsInterpolation implements Interpolation { } // Kochanek-Bartels tangent coefficients - final double ta = (1-tensionA)*(1+biasA)*(1+continuityA)/2; // Factor for lhs of d[i] - final double tb = (1-tensionA)*(1-biasA)*(1-continuityA)/2; // Factor for rhs of d[i] - final double tc = (1-tensionB)*(1+biasB)*(1-continuityB)/2; // Factor for lhs of d[i+1] - final double td = (1-tensionB)*(1-biasB)*(1+continuityB)/2; // Factor for rhs of d[i+1] + final double ta = (1 - tensionA) * (1 + biasA) * (1 + continuityA) / 2; // Factor for lhs of d[i] + final double tb = (1 - tensionA) * (1 - biasA) * (1 - continuityA) / 2; // Factor for rhs of d[i] + final double tc = (1 - tensionB) * (1 + biasB) * (1 - continuityB) / 2; // Factor for lhs of d[i+1] + final double td = (1 - tensionB) * (1 - biasB) * (1 + continuityB) / 2; // Factor for rhs of d[i+1] - coeffA[i] = linearCombination(i, -ta, ta- tb-tc+2, tb+tc-td-2, td); - coeffB[i] = linearCombination(i, 2*ta, -2*ta+2*tb+tc-3, -2*tb-tc+td+3, -td); - coeffC[i] = linearCombination(i, -ta, ta- tb , tb , 0); + coeffA[i] = linearCombination(i, -ta, ta - tb - tc + 2, tb + tc - td - 2, td); + coeffB[i] = linearCombination(i, 2 * ta, -2 * ta + 2 * tb + tc - 3, -2 * tb - tc + td + 3, -td); + coeffC[i] = linearCombination(i, -ta, ta - tb, tb, 0); //coeffD[i] = linearCombination(i, 0, 1, 0, 0); coeffD[i] = retrieve(i); // this is an optimization } @@ -125,11 +126,13 @@ public class KochanekBartelsInterpolation implements Interpolation { * @return nodes[clamp(0, nodes.length-1)] */ private Vector3 retrieve(int index) { - if (index < 0) + if (index < 0) { return fastRetrieve(0); + } - if (index >= nodes.size()) - return fastRetrieve(nodes.size()-1); + if (index >= nodes.size()) { + return fastRetrieve(nodes.size() - 1); + } return fastRetrieve(index); } @@ -140,11 +143,13 @@ public class KochanekBartelsInterpolation implements Interpolation { @Override public Vector3 getPosition(double position) { - if (coeffA == null) + if (coeffA == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return null; + } position *= scaling; @@ -166,11 +171,13 @@ public class KochanekBartelsInterpolation implements Interpolation { @Override public Vector3 get1stDerivative(double position) { - if (coeffA == null) + if (coeffA == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return null; + } position *= scaling; @@ -181,16 +188,18 @@ public class KochanekBartelsInterpolation implements Interpolation { final Vector3 b = coeffB[index]; final Vector3 c = coeffC[index]; - return a.multiply(1.5*position - 3.0*index).add(b).multiply(2.0*position).add(a.multiply(1.5*index).subtract(b).multiply(2.0*index)).add(c).multiply(scaling); + return a.multiply(1.5 * position - 3.0 * index).add(b).multiply(2.0 * position).add(a.multiply(1.5 * index).subtract(b).multiply(2.0 * index)).add(c).multiply(scaling); } @Override public double arcLength(double positionA, double positionB) { - if (coeffA == null) + if (coeffA == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (positionA > positionB) + if (positionA > positionB) { return arcLength(positionB, positionA); + } positionA *= scaling; positionB *= scaling; @@ -205,23 +214,21 @@ public class KochanekBartelsInterpolation implements Interpolation { } /** - * Assumes a < b + * Assumes a < b. */ private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) { switch (indexRight - indexLeft) { - case 0: - return arcLengthRecursive(indexLeft, remainderLeft, remainderRight); + case 0: + return arcLengthRecursive(indexLeft, remainderLeft, remainderRight); - case 1: - // This case is merely a speed-up for a very common case - return - arcLengthRecursive(indexLeft, remainderLeft, 1.0) + - arcLengthRecursive(indexRight, 0.0, remainderRight); + case 1: + // This case is merely a speed-up for a very common case + return arcLengthRecursive(indexLeft, remainderLeft, 1.0) + + arcLengthRecursive(indexRight, 0.0, remainderRight); - default: - return - arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0) + - arcLengthRecursive(indexRight, 0.0, remainderRight); + default: + return arcLengthRecursive(indexLeft, remainderLeft, indexRight - 1, 1.0) + + arcLengthRecursive(indexRight, 0.0, remainderRight); } } @@ -233,9 +240,9 @@ public class KochanekBartelsInterpolation implements Interpolation { final int nPoints = 8; double accum = a.multiply(remainderLeft).add(b).multiply(remainderLeft).add(c).length() / 2.0; - for (int i = 1; i < nPoints-1; ++i) { + for (int i = 1; i < nPoints - 1; ++i) { double t = ((double) i) / nPoints; - t = (remainderRight-remainderLeft)*t + remainderLeft; + t = (remainderRight - remainderLeft) * t + remainderLeft; accum += a.multiply(t).add(b).multiply(t).add(c).length(); } @@ -245,11 +252,13 @@ public class KochanekBartelsInterpolation implements Interpolation { @Override public int getSegment(double position) { - if (coeffA == null) + if (coeffA == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return Integer.MAX_VALUE; + } position *= scaling; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java index 1378ddd14..54c700e09 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // $Id$ @@ -37,17 +37,19 @@ public class LinearInterpolation implements Interpolation { @Override public void setNodes(List nodes) { checkNotNull(nodes); - + this.nodes = nodes; } @Override public Vector3 getPosition(double position) { - if (nodes == null) + if (nodes == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return null; + } position *= nodes.size() - 1; @@ -77,11 +79,13 @@ public class LinearInterpolation implements Interpolation { @Override public Vector3 get1stDerivative(double position) { - if (nodes == null) + if (nodes == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return null; + } position *= nodes.size() - 1; @@ -95,11 +99,13 @@ public class LinearInterpolation implements Interpolation { @Override public double arcLength(double positionA, double positionB) { - if (nodes == null) + if (nodes == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (positionA > positionB) + if (positionA > positionB) { return arcLength(positionB, positionA); + } positionA *= nodes.size() - 1; positionB *= nodes.size() - 1; @@ -118,19 +124,17 @@ public class LinearInterpolation implements Interpolation { */ private double arcLengthRecursive(int indexA, double remainderA, int indexB, double remainderB) { switch (indexB - indexA) { - case 0: - return arcLengthRecursive(indexA, remainderA, remainderB); + case 0: + return arcLengthRecursive(indexA, remainderA, remainderB); - case 1: - // This case is merely a speed-up for a very common case - return - arcLengthRecursive(indexA, remainderA, 1.0) + - arcLengthRecursive(indexB, 0.0, remainderB); + case 1: + // This case is merely a speed-up for a very common case + return arcLengthRecursive(indexA, remainderA, 1.0) + + arcLengthRecursive(indexB, 0.0, remainderB); - default: - return - arcLengthRecursive(indexA, remainderA, indexB - 1, 1.0) + - arcLengthRecursive(indexB, 0.0, remainderB); + default: + return arcLengthRecursive(indexA, remainderA, indexB - 1, 1.0) + + arcLengthRecursive(indexB, 0.0, remainderB); } } @@ -143,11 +147,13 @@ public class LinearInterpolation implements Interpolation { @Override public int getSegment(double position) { - if (nodes == null) + if (nodes == null) { throw new IllegalStateException("Must call setNodes first."); + } - if (position > 1) + if (position > 1) { return Integer.MAX_VALUE; + } position *= nodes.size() - 1; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java index 3a020653e..d9fcf96c5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // $Id$ diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java index 23680f2bc..be299b249 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ // $Id$ @@ -47,7 +47,7 @@ public class ReparametrisingInterpolation implements Interpolation { public ReparametrisingInterpolation(Interpolation baseInterpolation) { checkNotNull(baseInterpolation); - + this.baseInterpolation = baseInterpolation; } @@ -67,16 +67,18 @@ public class ReparametrisingInterpolation implements Interpolation { @Override public Vector3 getPosition(double position) { - if (position > 1) + if (position > 1) { return null; + } return baseInterpolation.getPosition(arcToParameter(position)); } @Override public Vector3 get1stDerivative(double position) { - if (position > 1) + if (position > 1) { return null; + } return baseInterpolation.get1stDerivative(arcToParameter(position)).normalize().multiply(totalArcLength); } @@ -87,10 +89,13 @@ public class ReparametrisingInterpolation implements Interpolation { } private double arcToParameter(double arc) { - if (cache.isEmpty()) + if (cache.isEmpty()) { throw new IllegalStateException("Must call setNodes first."); + } - if (arc > 1) arc = 1; + if (arc > 1) { + arc = 1; + } arc *= totalArcLength; Entry floorEntry = cache.floorEntry(arc); @@ -140,8 +145,7 @@ public class ReparametrisingInterpolation implements Interpolation { // search between left and mid rightArc = midArc; rightParameter = midParameter; - } - else { + } else { // search between mid and right leftArc = midArc; leftParameter = midParameter; @@ -152,8 +156,9 @@ public class ReparametrisingInterpolation implements Interpolation { @Override public int getSegment(double position) { - if (position > 1) + if (position > 1) { return Integer.MAX_VALUE; + } return baseInterpolation.getSegment(arcToParameter(position)); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java index 97f8b8920..a7f3fe449 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/JLibNoiseGenerator.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java index 185e41fbb..98a7b9f83 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/NoiseGenerator.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/PerlinNoise.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/PerlinNoise.java index ced3c0e67..bf0f3493e 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/PerlinNoise.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/PerlinNoise.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java index ff3421404..fb7546f81 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RidgedMultiFractalNoise.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RidgedMultiFractalNoise.java index 0ebd0de57..fdfb4461f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RidgedMultiFractalNoise.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/RidgedMultiFractalNoise.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/VoronoiNoise.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/VoronoiNoise.java index af1b5260e..35de40eda 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/VoronoiNoise.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/noise/VoronoiNoise.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.noise; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index 1dd893484..c895d1f4b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.transform; @@ -34,15 +34,13 @@ import java.io.Serializable; */ public class AffineTransform implements Transform, Serializable { - private AffineTransform inverse; - /** * coefficients for x coordinate. */ private final double m00; private final double m01; private final double m02; - private double m03; + private final double m03; /** * coefficients for y coordinate. @@ -50,7 +48,7 @@ public class AffineTransform implements Transform, Serializable { private final double m10; private final double m11; private final double m12; - private double m13; + private final double m13; /** * coefficients for z coordinate. @@ -58,13 +56,13 @@ public class AffineTransform implements Transform, Serializable { private final double m20; private final double m21; private final double m22; - private double m23; + private final double m23; // =================================================================== // constructors /** - * Creates a new affine transform3D set to identity. + * Creates a new affine transform3D set to the identity. */ public AffineTransform() { // init to identity matrix @@ -85,6 +83,7 @@ public class AffineTransform implements Transform, Serializable { m20 = coefs[6]; m21 = coefs[7]; m22 = coefs[8]; + m03 = m13 = m23 = 0; } else if (coefs.length == 12) { m00 = coefs[0]; m01 = coefs[1]; @@ -99,11 +98,14 @@ public class AffineTransform implements Transform, Serializable { m22 = coefs[10]; m23 = coefs[11]; } else { - throw new IllegalArgumentException("Input array must have 9 or 12 elements"); + throw new IllegalArgumentException( + "Input array must have 9 or 12 elements"); } } - public AffineTransform(double xx, double yx, double zx, double tx, double xy, double yy, double zy, double ty, double xz, double yz, double zz, double tz) { + public AffineTransform(double xx, double yx, double zx, double tx, + double xy, double yy, double zy, double ty, double xz, double yz, + double zz, double tz) { m00 = xx; m01 = yx; m02 = zx; @@ -123,40 +125,10 @@ public class AffineTransform implements Transform, Serializable { @Override public boolean isIdentity() { - if (m00 != 1) { - return false; - } - if (m11 != 1) { - return false; - } - if (m22 != 1) { - return false; - } - if (m01 != 0) { - return false; - } - if (m02 != 0) { - return false; - } - if (m03 != 0) { - return false; - } - if (m10 != 0) { - return false; - } - if (m12 != 0) { - return false; - } - if (m13 != 0) { - return false; - } - if (m20 != 0) { - return false; - } - if (m21 != 0) { - return false; - } - return m23 == 0; + return m00 == m11 && m11 == m22 && m22 == 1 + && m01 == m02 && m02 == m03 && m03 == 0 + && m10 == m12 && m12 == m13 && m13 == 0 + && m20 == m21 && m21 == m23 && m23 == 0; } /** @@ -164,20 +136,7 @@ public class AffineTransform implements Transform, Serializable { * 12 double. */ public double[] coefficients() { - return new double[] { - m00, - m01, - m02, - m03, - m10, - m11, - m12, - m13, - m20, - m21, - m22, - m23 - }; + return new double[]{m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23}; } public boolean isOffAxis() { @@ -198,8 +157,8 @@ public class AffineTransform implements Transform, Serializable { * @return the determinant of the transform. */ private double determinant() { - return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12) + m02 * (m10 * m21 - - m20 * m11); + return m00 * (m11 * m22 - m12 * m21) - m01 * (m10 * m22 - m20 * m12) + + m02 * (m10 * m21 - m20 * m11); } /** @@ -207,26 +166,23 @@ public class AffineTransform implements Transform, Serializable { */ @Override public AffineTransform inverse() { - if (inverse != null) { - return inverse; - } double det = this.determinant(); return new AffineTransform( - (m11 * m22 - m21 * m12) / det, - (m21 * m02 - m01 * m22) / det, - (m01 * m12 - m11 * m02) / det, - (m01 * (m22 * m13 - m12 * m23) + m02 * (m11 * m23 - m21 * m13) - m03 * (m11 * m22 - - m21 * m12)) / det, - (m20 * m12 - m10 * m22) / det, - (m00 * m22 - m20 * m02) / det, - (m10 * m02 - m00 * m12) / det, - (m00 * (m12 * m23 - m22 * m13) - m02 * (m10 * m23 - m20 * m13) + m03 * (m10 * m22 - - m20 * m12)) / det, - (m10 * m21 - m20 * m11) / det, - (m20 * m01 - m00 * m21) / det, - (m00 * m11 - m10 * m01) / det, - (m00 * (m21 * m13 - m11 * m23) + m01 * (m10 * m23 - m20 * m13) - m03 * (m10 * m21 - - m20 * m11)) / det); + (m11 * m22 - m21 * m12) / det, + (m21 * m02 - m01 * m22) / det, + (m01 * m12 - m11 * m02) / det, + (m01 * (m22 * m13 - m12 * m23) + m02 * (m11 * m23 - m21 * m13) + - m03 * (m11 * m22 - m21 * m12)) / det, + (m20 * m12 - m10 * m22) / det, + (m00 * m22 - m20 * m02) / det, + (m10 * m02 - m00 * m12) / det, + (m00 * (m12 * m23 - m22 * m13) - m02 * (m10 * m23 - m20 * m13) + + m03 * (m10 * m22 - m20 * m12)) / det, + (m10 * m21 - m20 * m11) / det, + (m20 * m01 - m00 * m21) / det, + (m00 * m11 - m10 * m01) / det, + (m00 * (m21 * m13 - m11 * m23) + m01 * (m10 * m23 - m20 * m13) + - m03 * (m10 * m21 - m20 * m11)) / det); } // =================================================================== @@ -252,7 +208,10 @@ public class AffineTransform implements Transform, Serializable { double n21 = m20 * that.m01 + m21 * that.m11 + m22 * that.m21; double n22 = m20 * that.m02 + m21 * that.m12 + m22 * that.m22; double n23 = m20 * that.m03 + m21 * that.m13 + m22 * that.m23 + m23; - return new AffineTransform(n00, n01, n02, n03, n10, n11, n12, n13, n20, n21, n22, n23); + return new AffineTransform( + n00, n01, n02, n03, + n10, n11, n12, n13, + n20, n21, n22, n23); } /** @@ -275,7 +234,10 @@ public class AffineTransform implements Transform, Serializable { double n21 = that.m20 * m01 + that.m21 * m11 + that.m22 * m21; double n22 = that.m20 * m02 + that.m21 * m12 + that.m22 * m22; double n23 = that.m20 * m03 + that.m21 * m13 + that.m22 * m23 + that.m23; - return new AffineTransform(n00, n01, n02, n03, n10, n11, n12, n13, n20, n21, n22, n23); + return new AffineTransform( + n00, n01, n02, n03, + n10, n11, n12, n13, + n20, n21, n22, n23); } public AffineTransform translate(Vector3 vec) { @@ -293,19 +255,31 @@ public class AffineTransform implements Transform, Serializable { public AffineTransform rotateX(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate(new AffineTransform(1, 0, 0, 0, 0, cot, -sit, 0, 0, sit, cot, 0)); + return concatenate( + new AffineTransform( + 1, 0, 0, 0, + 0, cot, -sit, 0, + 0, sit, cot, 0)); } public AffineTransform rotateY(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate(new AffineTransform(cot, 0, sit, 0, 0, 1, 0, 0, -sit, 0, cot, 0)); + return concatenate( + new AffineTransform( + cot, 0, sit, 0, + 0, 1, 0, 0, + -sit, 0, cot, 0)); } public AffineTransform rotateZ(double theta) { double cot = MathUtils.dCos(theta); double sit = MathUtils.dSin(theta); - return concatenate(new AffineTransform(cot, -sit, 0, 0, sit, cot, 0, 0, 0, 0, 1, 0)); + return concatenate( + new AffineTransform( + cot, -sit, 0, 0, + sit, cot, 0, 0, + 0, 0, 1, 0)); } public AffineTransform scale(double s) { @@ -361,13 +335,20 @@ public class AffineTransform implements Transform, Serializable { } /** - * Returns if this affine transform is representing a horizontal flip. + * Returns if this affine transform represents a horizontal flip. */ public boolean isHorizontalFlip() { // use the determinant of the x-z submatrix to check if this is a horizontal flip return m00 * m22 - m02 * m20 < 0; } + /** + * Returns if this affine transform represents a vertical flip. + */ + public boolean isVerticalFlip() { + return m11 < 0; + } + @Override public String toString() { return String.format("Affine[%g %g %g %g, %g %g %g %g, %g %g %g %g]}", m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java index 0baf52899..6cac5085b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/CombinedTransform.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.transform; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java index f9f1ed125..d4efde906 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Identity.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.transform; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java index 91d347f7c..0679f9ebe 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/RoundedTransform.java @@ -2,7 +2,7 @@ package com.sk89q.worldedit.math.transform; import com.sk89q.worldedit.math.Vector3; -public class RoundedTransform implements Transform{ +public class RoundedTransform implements Transform { private final Transform transform; public RoundedTransform(Transform transform) { @@ -17,7 +17,8 @@ public class RoundedTransform implements Transform{ @Override public Vector3 apply(Vector3 input) { Vector3 val = transform.apply(input); - return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math.floor(val.getY() + 0.5)); + return Vector3.at(Math.floor(val.getX() + 0.5), Math.floor(val.getY() + 0.5), Math + .floor(val.getY() + 0.5)); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java index e12030022..d108adda6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transform.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.transform; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java index 71286507b..aee830834 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/math/transform/Transforms.java @@ -3,18 +3,18 @@ * Copyright (C) sk89q * Copyright (C) WorldEdit team and contributors * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published by the - * Free Software Foundation, either version 3 of the License, or + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License - * for more details. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * You should have received a copy of the GNU Lesser General Public License - * along with this program. If not, see . + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ package com.sk89q.worldedit.math.transform;