Skip to content

Commit

Permalink
joltjni: add 4 "loadX" methods
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Feb 24, 2025
1 parent 7036318 commit 010391d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Quat.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ public Quat(Vec3Arg v, float w) {
// *************************************************************************
// new methods exposed

/**
* Set the current quaternion to identity.
*/
public void loadIdentity() {
this.x = 0f;
this.y = 0f;
this.z = 0f;
this.w = 1f;
}

/**
* Set all 4 components to specified values.
*
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/RVec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ public RVec3 addLocal(double addX, double addY, double addZ) {
return this;
}

/**
* Set all components to 0.
*/
public void loadZero() {
this.xx = 0.;
this.yy = 0.;
this.zz = 0.;
}

/**
* Test whether all 3 components are finite.
*
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Vec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,24 @@ public void addInPlace(float xOffset, float yOffset, float zOffset) {
this.z += zOffset;
}

/**
* Set all components to 1.
*/
public void loadOne() {
this.x = 1f;
this.y = 1f;
this.z = 1f;
}

/**
* Set all components to 0.
*/
public void loadZero() {
this.x = 0f;
this.y = 0f;
this.z = 0f;
}

/**
* Change the current vector to a unit vector with the same direction.
*/
Expand Down

0 comments on commit 010391d

Please sign in to comment.