Vector changes.

- Clarified some javadocs
- Optimized toBlockPoint and made it return a BlockVector instead of a Vector.
- Changed some whitespace
This commit is contained in:
TomyLobo 2012-01-05 16:08:53 +01:00
parent 8c68cdf4a8
commit e4d3f70594
2 changed files with 33 additions and 23 deletions

View File

@ -290,7 +290,7 @@ public Vector subtract(Vector... others) {
}
/**
* Multiplies two points.
* Component-wise multiplication
*
* @param other
* @return New point
@ -300,7 +300,7 @@ public Vector multiply(Vector other) {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@ -312,7 +312,7 @@ public Vector multiply(double x, double y, double z) {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@ -324,7 +324,7 @@ public Vector multiply(int x, int y, int z) {
}
/**
* Multiply points.
* Component-wise multiplication
*
* @param others
* @return New point
@ -371,7 +371,7 @@ public Vector multiply(int n) {
}
/**
* Divide two points.
* Component-wise division
*
* @param other
* @return New point
@ -381,7 +381,7 @@ public Vector divide(Vector other) {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@ -393,7 +393,7 @@ public Vector divide(double x, double y, double z) {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@ -565,7 +565,9 @@ public Vector ceil() {
}
/**
* 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
*/
@ -606,10 +608,12 @@ public Vector transform2D(double angle,
* @param z
* @return point
*/
public static Vector toBlockPoint(double x, double y, double z) {
return new Vector((int) Math.floor(x),
(int) Math.floor(y),
(int) Math.floor(z));
public static BlockVector toBlockPoint(double x, double y, double z) {
return new BlockVector(
Math.floor(x),
Math.floor(y),
Math.floor(z)
);
}
/**
@ -618,9 +622,11 @@ public static Vector toBlockPoint(double x, double y, double z) {
* @return point
*/
public BlockVector toBlockPoint() {
return new BlockVector((int) Math.floor(x),
(int) Math.floor(y),
(int) Math.floor(z));
return new BlockVector(
Math.floor(x),
Math.floor(y),
Math.floor(z)
);
}
/**
@ -634,6 +640,7 @@ public boolean equals(Object obj) {
if (!(obj instanceof Vector)) {
return false;
}
Vector other = (Vector) obj;
return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z;

View File

@ -246,7 +246,7 @@ public Vector2D subtract(Vector2D... others) {
}
/**
* Multiplies two points.
* Component-wise multiplication
*
* @param other
* @return New point
@ -256,7 +256,7 @@ public Vector2D multiply(Vector2D other) {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@ -268,7 +268,7 @@ public Vector2D multiply(double x, double z) {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@ -280,7 +280,7 @@ public Vector2D multiply(int x, int z) {
}
/**
* Multiply points.
* Component-wise multiplication
*
* @param others
* @return New point
@ -326,7 +326,7 @@ public Vector2D multiply(int n) {
}
/**
* Divide two points.
* Component-wise division
*
* @param other
* @return New point
@ -336,7 +336,7 @@ public Vector2D divide(Vector2D other) {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@ -348,7 +348,7 @@ public Vector2D divide(double x, double z) {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@ -491,7 +491,9 @@ public Vector2D ceil() {
}
/**
* 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
*/
@ -542,6 +544,7 @@ public boolean equals(Object obj) {
if (!(obj instanceof Vector2D)) {
return false;
}
Vector2D other = (Vector2D) obj;
return other.x == this.x && other.z == this.z;