Skip to content

Commit

Permalink
Integrate Long vectors with more other classes
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Jul 27, 2023
1 parent de9186c commit 5799e75
Show file tree
Hide file tree
Showing 3 changed files with 327 additions and 28 deletions.
79 changes: 79 additions & 0 deletions src/main/java/org/joml/Vector2L.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,18 @@ public Vector2L(Vector2Lc v) {
y = v.y();
}

/**
* Create a new {@link Vector2L} and initialize its components to the one of
* the given vector.
*
* @param v
* the {@link Vector2ic} to copy the values from
*/
public Vector2L(Vector2ic v) {
x = v.x();
y = v.y();
}

/**
* Create a new {@link Vector2L} and initialize its components to the rounded value of
* the given vector.
Expand Down Expand Up @@ -289,6 +301,19 @@ public Vector2L set(Vector2Lc v) {
return this;
}

/**
* Set this vector to the values of v.
*
* @param v
* the vector to copy from
* @return this
*/
public Vector2L set(Vector2ic v) {
this.x = v.x();
this.y = v.y();
return this;
}

/**
* Set this vector to the values of v using {@link RoundingMode#TRUNCATE} rounding.
* <p>
Expand Down Expand Up @@ -537,6 +562,24 @@ public Vector2L sub(Vector2Lc v, Vector2L dest) {
return dest;
}

/**
* Subtract the supplied vector from this one and store the result in
* <code>this</code>.
*
* @param v
* the vector to subtract
* @return this
*/
public Vector2L sub(Vector2ic v) {
return sub(v, this);
}

public Vector2L sub(Vector2ic v, Vector2L dest) {
dest.x = x - v.x();
dest.y = y - v.y();
return dest;
}

/**
* Decrement the components of this vector by the given values.
*
Expand Down Expand Up @@ -677,6 +720,25 @@ public Vector2L add(Vector2Lc v, Vector2L dest) {
return dest;
}

/**
* Add <code>v</code> to this vector.
*
* @param v
* the vector to add
* @return this
*/
public Vector2L add(Vector2ic v) {
this.x = x + v.x();
this.y = y + v.y();
return this;
}

public Vector2L add(Vector2ic v, Vector2L dest) {
dest.x = x + v.x();
dest.y = y + v.y();
return dest;
}

/**
* Increment the components of this vector by the given values.
*
Expand Down Expand Up @@ -731,6 +793,23 @@ public Vector2L mul(Vector2Lc v, Vector2L dest) {
return dest;
}

/**
* Add the supplied vector by this one.
*
* @param v
* the vector to multiply
* @return this
*/
public Vector2L mul(Vector2ic v) {
return mul(v, this);
}

public Vector2L mul(Vector2ic v, Vector2L dest) {
dest.x = x * v.x();
dest.y = y * v.y();
return dest;
}

/**
* Multiply the components of this vector by the given values.
*
Expand Down
Loading

0 comments on commit 5799e75

Please sign in to comment.