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 class Vector {
}
/**
* Multiplies two points.
* Component-wise multiplication
*
* @param other
* @return New point
@@ -300,7 +300,7 @@ public class Vector {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@@ -312,7 +312,7 @@ public class Vector {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@@ -324,7 +324,7 @@ public class Vector {
}
/**
* Multiply points.
* Component-wise multiplication
*
* @param others
* @return New point
@@ -371,7 +371,7 @@ public class Vector {
}
/**
* Divide two points.
* Component-wise division
*
* @param other
* @return New point
@@ -381,7 +381,7 @@ public class Vector {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@@ -393,7 +393,7 @@ public class Vector {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @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
*/
@@ -606,10 +608,12 @@ public class Vector {
* @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 class Vector {
* @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 class Vector {
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 class Vector2D {
}
/**
* Multiplies two points.
* Component-wise multiplication
*
* @param other
* @return New point
@@ -256,7 +256,7 @@ public class Vector2D {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@@ -268,7 +268,7 @@ public class Vector2D {
}
/**
* Multiply two points.
* Component-wise multiplication
*
* @param x
* @param y
@@ -280,7 +280,7 @@ public class Vector2D {
}
/**
* Multiply points.
* Component-wise multiplication
*
* @param others
* @return New point
@@ -326,7 +326,7 @@ public class Vector2D {
}
/**
* Divide two points.
* Component-wise division
*
* @param other
* @return New point
@@ -336,7 +336,7 @@ public class Vector2D {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @param y
@@ -348,7 +348,7 @@ public class Vector2D {
}
/**
* Divide two points.
* Component-wise division
*
* @param x
* @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
*/
@@ -542,6 +544,7 @@ public class Vector2D {
if (!(obj instanceof Vector2D)) {
return false;
}
Vector2D other = (Vector2D) obj;
return other.x == this.x && other.z == this.z;