@@ -142,6 +142,29 @@ public Vec3(Vec3Arg vec) {
142142 // *************************************************************************
143143 // new methods exposed
144144
145+ /**
146+ * Add the specified offsets.
147+ *
148+ * @param xOffset the amount to add to the X component
149+ * @param yOffset the amount to add to the Y component
150+ * @param zOffset the amount to add to the Z component
151+ */
152+ public void addInPlace (float xOffset , float yOffset , float zOffset ) {
153+ this .x += xOffset ;
154+ this .y += yOffset ;
155+ this .z += zOffset ;
156+ }
157+
158+ /**
159+ * Change the current vector to a unit vector with the same direction.
160+ */
161+ public void normalizeInPlace () {
162+ float invLength = 1f / length ();
163+ this .x *= invLength ;
164+ this .y *= invLength ;
165+ this .z *= invLength ;
166+ }
167+
145168 /**
146169 * Return the bitwise AND of the specified vectors.
147170 *
@@ -196,6 +219,19 @@ public static Vec3 sAxisZ() {
196219 return result ;
197220 }
198221
222+ /**
223+ * Separately scale each component.
224+ *
225+ * @param xScale the scale factor to apply to the X component
226+ * @param yScale the scale factor to apply to the Y component
227+ * @param zScale the scale factor to apply to the Z component
228+ */
229+ public void scaleInPlace (float xScale , float yScale , float zScale ) {
230+ this .x *= xScale ;
231+ this .y *= yScale ;
232+ this .z *= zScale ;
233+ }
234+
199235 /**
200236 * Set all 3 components to specified values.
201237 *
@@ -221,6 +257,17 @@ public void set(float[] array) {
221257 this .z = array [2 ];
222258 }
223259
260+ /**
261+ * Set all 3 components from the argument.
262+ *
263+ * @param source the vector to copy (not null, unaffected)
264+ */
265+ public void set (Vec3Arg source ) {
266+ this .x = source .getX ();
267+ this .y = source .getY ();
268+ this .z = source .getZ ();
269+ }
270+
224271 /**
225272 * Alter the first (X) component.
226273 *
@@ -403,6 +450,21 @@ public static Vec3 sSelect(Vec3Arg notSet, Vec3Arg set, UVec4Arg control) {
403450 return result ;
404451 }
405452
453+ /**
454+ * Replace any -0 elements with +0, in preparation for hashing.
455+ */
456+ public void standardizeInPlace () {
457+ if (Float .compare (x , -0f ) == 0 ) {
458+ this .x = 0f ;
459+ }
460+ if (Float .compare (y , -0f ) == 0 ) {
461+ this .y = 0f ;
462+ }
463+ if (Float .compare (z , -0f ) == 0 ) {
464+ this .z = 0f ;
465+ }
466+ }
467+
406468 /**
407469 * Return the component-wise sum of the specified vectors.
408470 *
0 commit comments