Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganize files, complete Kotlin extensions #323

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ java {
targetCompatibility = buildProfile == 'experimental' ? JavaVersion.current() : JavaVersion.VERSION_1_8
}

kotlin {
explicitApi()
}

test {
useJUnitPlatform()
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/joml/Matrix3x2f.java
Original file line number Diff line number Diff line change
Expand Up @@ -1664,7 +1664,7 @@ public Vector3f transform(Vector3f v) {
* will contain the result
* @return dest
*/
public Vector3f transform(Vector3f v, Vector3f dest) {
public Vector3f transform(Vector3fc v, Vector3f dest) {
return v.mul(this, dest);
}

Expand Down Expand Up @@ -1717,7 +1717,7 @@ public Vector2f transformPosition(Vector2f v) {
* In order to store the result in the same vector, use {@link #transformPosition(Vector2f)}.
*
* @see #transformPosition(Vector2f)
* @see #transform(Vector3f, Vector3f)
* @see #transform(Vector3fc, Vector3f)
*
* @param v
* the vector to transform
Expand All @@ -1741,7 +1741,7 @@ public Vector2f transformPosition(Vector2fc v, Vector2f dest) {
* In order to store the result in the same vector, use {@link #transformPosition(Vector2f)}.
*
* @see #transformPosition(Vector2f)
* @see #transform(Vector3f, Vector3f)
* @see #transform(Vector3fc, Vector3f)
*
* @param x
* the x component of the vector to transform
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/org/joml/Matrix3x2fc.java
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ public interface Matrix3x2fc {
* will contain the result
* @return dest
*/
Vector3f transform(Vector3f v, Vector3f dest);
Vector3f transform(Vector3fc v, Vector3f dest);

/**
* Transform/multiply the given vector <code>(x, y, z)</code> by this matrix and store the result in <code>dest</code>.
Expand Down Expand Up @@ -745,7 +745,7 @@ public interface Matrix3x2fc {
* In order to store the result in the same vector, use {@link #transformPosition(Vector2f)}.
*
* @see #transformPosition(Vector2f)
* @see #transform(Vector3f, Vector3f)
* @see #transform(Vector3fc, Vector3f)
*
* @param v
* the vector to transform
Expand All @@ -765,7 +765,7 @@ public interface Matrix3x2fc {
* In order to store the result in the same vector, use {@link #transformPosition(Vector2f)}.
*
* @see #transformPosition(Vector2f)
* @see #transform(Vector3f, Vector3f)
* @see #transform(Vector3fc, Vector3f)
*
* @param x
* the x component of the vector to transform
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joml/Matrix4d.java
Original file line number Diff line number Diff line change
Expand Up @@ -1894,7 +1894,7 @@ public Matrix4d mul(Matrix3x2fc right, Matrix4d dest) {
* the right operand of the multiplication
* @return this
*/
public Matrix4d mul(Matrix4f right) {
public Matrix4d mul(Matrix4fc right) {
return mul(right, this);
}

Expand Down
71 changes: 64 additions & 7 deletions src/main/java/org/joml/Quaterniond.java
Original file line number Diff line number Diff line change
Expand Up @@ -221,13 +221,7 @@ public Quaterniond add(double x, double y, double z, double w, Quaterniond dest)
* the quaternion to add to this
* @return this
*/
public Quaterniond add(Quaterniondc q2) {
x += q2.x();
y += q2.y();
z += q2.z();
w += q2.w();
return this;
}
public Quaterniond add(Quaterniondc q2) { return add(q2, this); }

public Quaterniond add(Quaterniondc q2, Quaterniond dest) {
dest.x = x + q2.x();
Expand All @@ -237,6 +231,48 @@ public Quaterniond add(Quaterniondc q2, Quaterniond dest) {
return dest;
}

/**
* Subtract the quaternion <code>(x, y, z, w)</code> from this quaternion.
*
* @param x
* the x component of the vector part
* @param y
* the y component of the vector part
* @param z
* the z component of the vector part
* @param w
* the real/scalar component
* @return this
*/
public Quaterniond sub(double x, double y, double z, double w) {
return sub(x, y, z, w, this);
}

public Quaterniond sub(double x, double y, double z, double w, Quaterniond dest) {
dest.x = this.x - x;
dest.y = this.y - y;
dest.z = this.z - z;
dest.w = this.w - w;
return dest;
}

/**
* Subtract <code>q2</code> from this quaternion.
*
* @param q2
* the quaternion to add to this
* @return this
*/
public Quaterniond sub(Quaterniondc q2) {return sub(q2, this);}

public Quaterniond sub(Quaterniondc q2, Quaterniond dest) {
dest.x = x - q2.x();
dest.y = y - q2.y();
dest.z = z - q2.z();
dest.w = w - q2.w();
return dest;
}

public double dot(Quaterniondc otherQuat) {
return this.x * otherQuat.x() + this.y * otherQuat.y() + this.z * otherQuat.z() + this.w * otherQuat.w();
}
Expand Down Expand Up @@ -1535,6 +1571,27 @@ public Quaterniond div(Quaterniondc b) {
return div(b, this);
}

public Quaterniond div(double d, Quaterniond dest) {
dest.x = x / d;
dest.y = y / d;
dest.z = z / d;
dest.w = w / d;
return this;
}

/**
* Divide this quaternion by the given scalar.
* <p>
* This method divides all the four components by the specified scalar.
*
* @param d
* the factor to divide all components by
* @return this
*/
public Quaterniond div(double d) {
return div(d, this);
}

/**
* Conjugate this quaternion.
*
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/org/joml/Quaterniondc.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,34 @@ public interface Quaterniondc {
*/
Quaterniond add(Quaterniondc q2, Quaterniond dest);

/**
* Subtract the quaternion <code>(x, y, z, w)</code> from this quaternion and store the result in <code>dest</code>.
*
* @param x
* the x component of the vector part
* @param y
* the y component of the vector part
* @param z
* the z component of the vector part
* @param w
* the real/scalar component
* @param dest
* will hold the result
* @return dest
*/
Quaterniond sub(double x, double y, double z, double w, Quaterniond dest);

/**
* Subtract <code>q2</code> from this quaternion and store the result in <code>dest</code>.
*
* @param q2
* the quaternion to add to this
* @param dest
* will hold the result
* @return dest
*/
Quaterniond sub(Quaterniondc q2, Quaterniond dest);

/**
* Return the dot product of this {@link Quaterniond} and <code>otherQuat</code>.
*
Expand Down Expand Up @@ -1345,6 +1373,19 @@ public interface Quaterniondc {
*/
Quaterniond div(Quaterniondc b, Quaterniond dest);

/**
* Divide this quaternion by the given scalar and store the result in <code>dest</code>.
* <p>
* This method divides all the four components by the specified scalar.
*
* @param d
* the factor to divide all components by
* @param dest
* will hold the result
* @return dest
*/
Quaterniond div(double d, Quaterniond dest);

/**
* Conjugate this quaternion and store the result in <code>dest</code>.
*
Expand Down
65 changes: 65 additions & 0 deletions src/main/java/org/joml/Quaternionf.java
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,50 @@ public Quaternionf add(Quaternionfc q2, Quaternionf dest) {
return dest;
}

/**
* Subtract the quaternion <code>(x, y, z, w)</code> from this quaternion.
*
* @param x
* the x component of the vector part
* @param y
* the y component of the vector part
* @param z
* the z component of the vector part
* @param w
* the real/scalar component
* @return this
*/
public Quaternionf sub(float x, float y, float z, float w) {
return sub(x, y, z, w, this);
}

public Quaternionf sub(float x, float y, float z, float w, Quaternionf dest) {
dest.x = this.x - x;
dest.y = this.y - y;
dest.z = this.z - z;
dest.w = this.w - w;
return dest;
}

/**
* Subtract <code>q2</code> from this quaternion.
*
* @param q2
* the quaternion to add to this
* @return this
*/
public Quaternionf sub(Quaternionfc q2) {
return sub(q2, this);
}

public Quaternionf sub(Quaternionfc q2, Quaternionf dest) {
dest.x = x - q2.x();
dest.y = y - q2.y();
dest.z = z - q2.z();
dest.w = w - q2.w();
return dest;
}

/**
* Return the dot of this quaternion and <code>otherQuat</code>.
*
Expand Down Expand Up @@ -1715,6 +1759,27 @@ public Quaternionf div(Quaternionfc b) {
return div(b, this);
}

public Quaternionf div(float f, Quaternionf dest) {
dest.x = x / f;
dest.y = y / f;
dest.z = z / f;
dest.w = w / f;
return this;
}

/**
* Divide this quaternion by the given scalar.
* <p>
* This method divides all the four components by the specified scalar.
*
* @param f
* the factor to divide all components by
* @return this
*/
public Quaternionf div(float f) {
return div(f, this);
}

/**
* Conjugate this quaternion.
*
Expand Down
43 changes: 42 additions & 1 deletion src/main/java/org/joml/Quaternionfc.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,34 @@ public interface Quaternionfc {
*/
Quaternionf add(Quaternionfc q2, Quaternionf dest);

/**
* Subtract the quaternion <code>(x, y, z, w)</code> from this quaternion and store the result in <code>dest</code>.
*
* @param x
* the x component of the vector part
* @param y
* the y component of the vector part
* @param z
* the z component of the vector part
* @param w
* the real/scalar component
* @param dest
* will hold the result
* @return dest
*/
Quaternionf sub(float x, float y, float z, float w, Quaternionf dest);

/**
* Subtract <code>q2</code> from this quaternion and store the result in <code>dest</code>.
*
* @param q2
* the quaternion to add to this
* @param dest
* will hold the result
* @return dest
*/
Quaternionf sub(Quaternionfc q2, Quaternionf dest);

/**
* Return the angle in radians represented by this normalized quaternion rotation.
* <p>
Expand Down Expand Up @@ -323,7 +351,7 @@ public interface Quaternionfc {
/**
* Multiply this quaternion by the given scalar and store the result in <code>dest</code>.
* <p>
* This method multiplies all of the four components by the specified scalar.
* This method multiplies all the four components by the specified scalar.
*
* @param f
* the factor to multiply all components by
Expand Down Expand Up @@ -1489,6 +1517,19 @@ public interface Quaternionfc {
*/
Quaternionf div(Quaternionfc b, Quaternionf dest);

/**
* Divide this quaternion by the given scalar and store the result in <code>dest</code>.
* <p>
* This method divides all the four components by the specified scalar.
*
* @param f
* the factor to divide all components by
* @param dest
* will hold the result
* @return dest
*/
Quaternionf div(float f, Quaternionf dest);

/**
* Conjugate this quaternion and store the result in <code>dest</code>.
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joml/Vector2d.java
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ public Vector2d div(double x, double y, Vector2d dest) {
* the vector to divide by
* @return this
*/
public Vector2d div(Vector2d v) {
public Vector2d div(Vector2dc v) {
this.x = x / v.x();
this.y = y / v.y();
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/joml/Vector3d.java
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,7 @@ public Vector3d mul(Vector3dc v, Vector3d dest) {
* the vector to divide by
* @return this
*/
public Vector3d div(Vector3d v) {
public Vector3d div(Vector3dc v) {
this.x = x / v.x();
this.y = y / v.y();
this.z = z / v.z();
Expand Down
Loading