Navigation Menu

Skip to content

Commit

Permalink
Add Vector3i.div() and Vector4i.div(float)/(int, Vector4i) overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
httpdigest committed Jan 27, 2020
1 parent 50359e9 commit 577ffa8
Show file tree
Hide file tree
Showing 4 changed files with 110 additions and 9 deletions.
44 changes: 44 additions & 0 deletions src/org/joml/Vector3i.java
Expand Up @@ -794,6 +794,50 @@ public Vector3i mul(int x, int y, int z, Vector3i dest) {
return dest;
}

/**
* Divide all components of this {@link Vector3i} by the given scalar value.
*
* @param scalar
* the scalar to divide by
* @return a vector holding the result
*/
public Vector3i div(float scalar) {
float invscalar = 1.0f / scalar;
this.x = (int) (x * invscalar);
this.y = (int) (y * invscalar);
this.z = (int) (z * invscalar);
return this;
}

public Vector3i div(float scalar, Vector3i dest) {
float invscalar = 1.0f / scalar;
dest.x = (int) (x * invscalar);
dest.y = (int) (y * invscalar);
dest.z = (int) (z * invscalar);
return dest;
}

/**
* Divide all components of this {@link Vector3i} by the given scalar value.
*
* @param scalar
* the scalar to divide by
* @return a vector holding the result
*/
public Vector3i div(int scalar) {
this.x = x / scalar;
this.y = y / scalar;
this.z = z / scalar;
return this;
}

public Vector3i div(int scalar, Vector3i dest) {
dest.x = x / scalar;
dest.y = y / scalar;
dest.z = z / scalar;
return dest;
}

/* (non-Javadoc)
* @see org.joml.Vector3ic#lengthSquared()
*/
Expand Down
24 changes: 24 additions & 0 deletions src/org/joml/Vector3ic.java
Expand Up @@ -226,6 +226,30 @@ public interface Vector3ic {
*/
Vector3i mul(int x, int y, int z, Vector3i dest);

/**
* Divide all components of this {@link Vector3i} by the given scalar value
* and store the result in <code>dest</code>.
*
* @param scalar
* the scalar to divide by
* @param dest
* will hold the result
* @return dest
*/
Vector3i div(float scalar, Vector3i dest);

/**
* Divide all components of this {@link Vector3i} by the given scalar value
* and store the result in <code>dest</code>.
*
* @param scalar
* the scalar to divide by
* @param dest
* will hold the result
* @return dest
*/
Vector3i div(int scalar, Vector3i dest);

/**
* Return the length squared of this vector.
*
Expand Down
39 changes: 30 additions & 9 deletions src/org/joml/Vector4i.java
Expand Up @@ -903,23 +903,21 @@ public Vector4i mul(int scalar, Vector4i dest) {
}

/**
* Divide all components of this {@link Vector4i} by the given scalar value.
* Divide all components of this {@link Vector3i} by the given scalar value.
*
* @param scalar
* the scalar to divide by
* @return a vector holding the result
*/
public Vector4i div(int scalar) {
this.x = x / scalar;
this.y = y / scalar;
this.z = z / scalar;
this.w = w / scalar;
public Vector4i div(float scalar) {
float invscalar = 1.0f / scalar;
this.x = (int) (x * invscalar);
this.y = (int) (y * invscalar);
this.z = (int) (z * invscalar);
this.w = (int) (w * invscalar);
return this;
}

/* (non-Javadoc)
* @see org.joml.Vector4ic#div(float, org.joml.Vector4i)
*/
public Vector4i div(float scalar, Vector4i dest) {
float invscalar = 1.0f / scalar;
dest.x = (int) (x * invscalar);
Expand All @@ -929,6 +927,29 @@ public Vector4i div(float scalar, Vector4i dest) {
return dest;
}

/**
* Divide all components of this {@link Vector4i} by the given scalar value.
*
* @param scalar
* the scalar to divide by
* @return a vector holding the result
*/
public Vector4i div(int scalar) {
this.x = x / scalar;
this.y = y / scalar;
this.z = z / scalar;
this.w = w / scalar;
return this;
}

public Vector4i div(int scalar, Vector4i dest) {
dest.x = x / scalar;
dest.y = y / scalar;
dest.z = z / scalar;
dest.w = w / scalar;
return dest;
}

/* (non-Javadoc)
* @see org.joml.Vector4ic#lengthSquared()
*/
Expand Down
12 changes: 12 additions & 0 deletions src/org/joml/Vector4ic.java
Expand Up @@ -244,6 +244,18 @@ public interface Vector4ic {
*/
Vector4i div(float scalar, Vector4i dest);

/**
* Divide all components of this {@link Vector4i} by the given scalar value
* and store the result in <code>dest</code>.
*
* @param scalar
* the scalar to divide by
* @param dest
* will hold the result
* @return dest
*/
Vector4i div(int scalar, Vector4i dest);

/**
* Return the length squared of this vector.
*
Expand Down

0 comments on commit 577ffa8

Please sign in to comment.