Skip to content

Commit

Permalink
Fixed errors from recent PR merge
Browse files Browse the repository at this point in the history
  • Loading branch information
tiggerbiggo committed Jun 15, 2018
1 parent 20b2fa1 commit a6275e1
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
34 changes: 17 additions & 17 deletions src/main/java/com/tiggerbiggo/primaplay/calculation/Vector2.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.io.Serializable;
import java.util.Random;

/** Represents real vector in 2D space. Also contains various methods for calculation. */
/** Represents a vector in 2D space. Also contains various methods for calculation. */
public class Vector2 implements Serializable {

private double x, y;

/**
* Constructs real new vector with X and Y components
* Constructs a new vector with X and Y components
*
* @param x The X component of the vector
* @param y The Y component of the vector
Expand Down Expand Up @@ -50,8 +50,8 @@ public Vector2 clone() {
/**
* Overridden toString with more descriptive info about this vector
*
* @return String in the format "[@<imaginary>hash code</imaginary>] -- X:
* <imaginary>X</imaginary>, Y: <3b>Y</imaginary>".
* @return String in the format "[@<b>hash code</b>] -- X:
* <b>X</b>, Y: <3b>Y</b>".
*/
@Override
public String toString() {
Expand Down Expand Up @@ -143,7 +143,7 @@ public double sqMagnitude() {
}

/**
* Applies real modulo operation on both components of the input vector given real value
* Applies a modulo operation on both components of the input vector given a value
*
* @param mod The modulo value
* @return The calculated number
Expand All @@ -156,7 +156,7 @@ public Vector2 mod(float mod) {
* Calculates the dot product of 2 vectors
*
* @param other The vector to dot with
* @return The dot product: <imaginary>ax*bx + ay*by</imaginary>
* @return The dot product: <b>ax*bx + ay*by</b>
*/
public double dot(Vector2 other) {
return (this.x * other.x) + (this.y * other.y);
Expand All @@ -166,14 +166,14 @@ public double dot(Vector2 other) {
* Calculates the determinant of 2 vectors
*
* @param other The vector to det with
* @return The determinant: <imaginary>ax*by - ay*bx</imaginary>
* @return The determinant: <b>ax*by - ay*bx</b>
*/
public double det(Vector2 other) {
return (this.x * other.y) - (this.y * other.x);
}

/**
* Linearly interpolates between 2 vectors given real percentage
* Linearly interpolates between 2 vectors given a percentage
*
* @param other The vector to lerp with
* @param p A double representing the percentage.
Expand All @@ -187,7 +187,7 @@ public Vector2 lerpVector(Vector2 other, double p) {
/**
* Gets the distance between 2 vectors
*
* @param b The second vector
* @param other The second vector
* @return The distance between the 2 vectors
*/
public double distanceBetween(Vector2 other) {
Expand Down Expand Up @@ -217,7 +217,7 @@ public double angleBetween(Vector2 other) {
}

/**
* Generates real random vector which lies on real given circle, the center of which is <code>this
* Generates a random vector which lies on a given circle, the center of which is <code>this
* </code>.
*
* @param r The radius of the circle
Expand All @@ -226,7 +226,7 @@ public double angleBetween(Vector2 other) {
public Vector2 randomOnCircle(double r) {
// Generate random angle
double rand = new Random().nextDouble() * Math.PI * 2;
// Make real new vector with length of the radius of the circle which we then rotate
// Make a new vector with length of the radius of the circle which we then rotate
Vector2 toReturn = Vector2.UP.multiply(new Vector2(r));
toReturn = toReturn.rotateAround(Vector2.ZERO, rand);
// Add the center point to offset it
Expand All @@ -237,7 +237,7 @@ public Vector2 randomOnCircle(double r) {
* Multiplies this vector by another
*
* @param other Second vector
* @return real*imaginary
* @return a*b
*/
public Vector2 multiply(Vector2 other) {
return new Vector2(this.X() * other.X(), this.Y() * other.Y());
Expand All @@ -247,7 +247,7 @@ public Vector2 multiply(Vector2 other) {
* Divides this vector by another
*
* @param other Second vector
* @return real/imaginary
* @return a/b
*/
public Vector2 divide(Vector2 other) {
return new Vector2(this.X() / other.X(), this.Y() / other.Y());
Expand All @@ -257,7 +257,7 @@ public Vector2 divide(Vector2 other) {
* Adds this vector to another
*
* @param other Second vector
* @return real+imaginary
* @return a+b
*/
public Vector2 add(Vector2 other) {
return new Vector2(this.X() + other.X(), this.Y() + other.Y());
Expand All @@ -267,7 +267,7 @@ public Vector2 add(Vector2 other) {
* Subtracts this vector from another
*
* @param other Second vector
* @return real-imaginary
* @return a-b
*/
public Vector2 subtract(Vector2 other) {
return new Vector2(this.X() - other.X(), this.Y() - other.Y());
Expand All @@ -279,7 +279,7 @@ public Vector2 abs() {
}

/**
* Returns real normalized (magnitude = 1) copy of real given Vector
* Returns a normalized (magnitude = 1) copy of a given Vector
*
* <p>Special Cases:
*
Expand All @@ -298,7 +298,7 @@ public Vector2 normalize() {
}

/**
* Rotates real given vector around real point and returns the result
* Rotates a given vector around a point and returns the result
*
* @param rotatePoint The point to rotate around
* @param angleRadians The angle to rotate in radians
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public class ImageTools {
public static Color colorFromPosition(SafeImage img, Vector2 pos){
//denormalise the input vector
pos = Vector2.multiply(pos, img.getDimensions());
pos = pos.multiply(img.getDimensions());

//get x and y
int x, y;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public SafeImage(int width, int height) throws IllegalArgumentException {
public Vector2 sizeAsVector(){return new Vector2(width, height);}

public Vector2 denormVector(Vector2 in){
return Vector2.multiply(in, sizeAsVector());
return in.multiply(sizeAsVector());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public Vector2[] get(RenderParams p) {
Vector2 A, B;
A = inA.get(p);
B = inB.get(p);
Vector2[] toReturn = new Vector2[p.n()];
for (int i = 0; i < p.n(); i++) {
toReturn[i] = A.lerpVector(B, func.apply((double) i / p.n()));
Vector2[] toReturn = new Vector2[p.frameNum()];
for (int i = 0; i < p.frameNum(); i++) {
toReturn[i] = A.lerpVector(B, func.apply((double) i / p.frameNum()));
}
return toReturn;
}
Expand Down

0 comments on commit a6275e1

Please sign in to comment.