Skip to content

Commit

Permalink
add array-oriented setters to the RVec3 and Quat classes
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Dec 6, 2024
1 parent 297500b commit 720e065
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/Quat.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,19 @@ public void set(float x, float y, float z, float w) {
this.w = w;
}

/**
* Set all 4 components from the specified array.
*
* @param array the desired component values (not null, length≥4,
* unaffected)
*/
public void set(float[] array) {
this.x = array[0];
this.y = array[1];
this.z = array[2];
this.w = array[3];
}

/**
* Create a rotation quaternion from Euler angles. Rotation order is X then
* Y then Z.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/com/github/stephengold/joltjni/RVec3.java
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,18 @@ public void set(double x, double y, double z) {
this.zz = z;
}

/**
* Set all 3 components from the specified array.
*
* @param array the desired component values (not null, length≥3,
* unaffected)
*/
public void set(double[] array) {
this.xx = array[0];
this.yy = array[1];
this.zz = array[2];
}

/**
* Alter the first (X) component.
*
Expand Down

0 comments on commit 720e065

Please sign in to comment.