Vector changes.

- Clarified some javadocs
- Optimized toBlockPoint and made it return a BlockVector instead of a Vector.
- Changed some whitespace
Dieser Commit ist enthalten in:
TomyLobo 2012-01-05 16:08:53 +01:00
Ursprung 8c68cdf4a8
Commit e4d3f70594
2 geänderte Dateien mit 33 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -290,7 +290,7 @@ public class Vector {
} }
/** /**
* Multiplies two points. * Component-wise multiplication
* *
* @param other * @param other
* @return New point * @return New point
@ -300,7 +300,7 @@ public class Vector {
} }
/** /**
* Multiply two points. * Component-wise multiplication
* *
* @param x * @param x
* @param y * @param y
@ -312,7 +312,7 @@ public class Vector {
} }
/** /**
* Multiply two points. * Component-wise multiplication
* *
* @param x * @param x
* @param y * @param y
@ -324,7 +324,7 @@ public class Vector {
} }
/** /**
* Multiply points. * Component-wise multiplication
* *
* @param others * @param others
* @return New point * @return New point
@ -371,7 +371,7 @@ public class Vector {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param other * @param other
* @return New point * @return New point
@ -381,7 +381,7 @@ public class Vector {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param x * @param x
* @param y * @param y
@ -393,7 +393,7 @@ public class Vector {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param x * @param x
* @param y * @param y
@ -565,7 +565,9 @@ public class Vector {
} }
/** /**
* Rounds all components to the closest integer. * Rounds all components to the closest integer.<br>
*<br>
* Components < 0.5 are rounded down, otherwise up
* *
* @return * @return
*/ */
@ -606,10 +608,12 @@ public class Vector {
* @param z * @param z
* @return point * @return point
*/ */
public static Vector toBlockPoint(double x, double y, double z) { public static BlockVector toBlockPoint(double x, double y, double z) {
return new Vector((int) Math.floor(x), return new BlockVector(
(int) Math.floor(y), Math.floor(x),
(int) Math.floor(z)); Math.floor(y),
Math.floor(z)
);
} }
/** /**
@ -618,9 +622,11 @@ public class Vector {
* @return point * @return point
*/ */
public BlockVector toBlockPoint() { public BlockVector toBlockPoint() {
return new BlockVector((int) Math.floor(x), return new BlockVector(
(int) Math.floor(y), Math.floor(x),
(int) Math.floor(z)); Math.floor(y),
Math.floor(z)
);
} }
/** /**
@ -634,6 +640,7 @@ public class Vector {
if (!(obj instanceof Vector)) { if (!(obj instanceof Vector)) {
return false; return false;
} }
Vector other = (Vector) obj; Vector other = (Vector) obj;
return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z; return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z;

Datei anzeigen

@ -246,7 +246,7 @@ public class Vector2D {
} }
/** /**
* Multiplies two points. * Component-wise multiplication
* *
* @param other * @param other
* @return New point * @return New point
@ -256,7 +256,7 @@ public class Vector2D {
} }
/** /**
* Multiply two points. * Component-wise multiplication
* *
* @param x * @param x
* @param y * @param y
@ -268,7 +268,7 @@ public class Vector2D {
} }
/** /**
* Multiply two points. * Component-wise multiplication
* *
* @param x * @param x
* @param y * @param y
@ -280,7 +280,7 @@ public class Vector2D {
} }
/** /**
* Multiply points. * Component-wise multiplication
* *
* @param others * @param others
* @return New point * @return New point
@ -326,7 +326,7 @@ public class Vector2D {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param other * @param other
* @return New point * @return New point
@ -336,7 +336,7 @@ public class Vector2D {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param x * @param x
* @param y * @param y
@ -348,7 +348,7 @@ public class Vector2D {
} }
/** /**
* Divide two points. * Component-wise division
* *
* @param x * @param x
* @param y * @param y
@ -491,7 +491,9 @@ public class Vector2D {
} }
/** /**
* Rounds all components to the closest integer. * Rounds all components to the closest integer.<br>
*<br>
* Components < 0.5 are rounded down, otherwise up
* *
* @return * @return
*/ */
@ -542,6 +544,7 @@ public class Vector2D {
if (!(obj instanceof Vector2D)) { if (!(obj instanceof Vector2D)) {
return false; return false;
} }
Vector2D other = (Vector2D) obj; Vector2D other = (Vector2D) obj;
return other.x == this.x && other.z == this.z; return other.x == this.x && other.z == this.z;