@@ -142,6 +142,29 @@ public Vec3(Vec3Arg vec) {
142
142
// *************************************************************************
143
143
// new methods exposed
144
144
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
+
145
168
/**
146
169
* Return the bitwise AND of the specified vectors.
147
170
*
@@ -196,6 +219,19 @@ public static Vec3 sAxisZ() {
196
219
return result ;
197
220
}
198
221
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
+
199
235
/**
200
236
* Set all 3 components to specified values.
201
237
*
@@ -221,6 +257,17 @@ public void set(float[] array) {
221
257
this .z = array [2 ];
222
258
}
223
259
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
+
224
271
/**
225
272
* Alter the first (X) component.
226
273
*
@@ -403,6 +450,21 @@ public static Vec3 sSelect(Vec3Arg notSet, Vec3Arg set, UVec4Arg control) {
403
450
return result ;
404
451
}
405
452
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
+
406
468
/**
407
469
* Return the component-wise sum of the specified vectors.
408
470
*
0 commit comments