@@ -53,7 +53,7 @@ public class DiscreteTransform2 {
53
53
private final Vector3d matrixRow0 ;
54
54
private final Vector3d matrixRow1 ;
55
55
56
- private DiscreteTransform2 (Matrix3d matrix ) {
56
+ private DiscreteTransform2 (final Matrix3d matrix ) {
57
57
this .matrix = matrix ;
58
58
this .matrixRow0 = matrix .row (0 );
59
59
this .matrixRow1 = matrix .row (1 );
@@ -75,7 +75,7 @@ public Matrix3d matrix() {
75
75
* @param vector The original vector
76
76
* @return The transformed vector
77
77
*/
78
- public Vector2i transform (Vector2i vector ) {
78
+ public Vector2i transform (final Vector2i vector ) {
79
79
return this .transform (vector .x (), vector .y ());
80
80
}
81
81
@@ -87,7 +87,7 @@ public Vector2i transform(Vector2i vector) {
87
87
* @param y The y coordinate of the original vector
88
88
* @return The transformed vector
89
89
*/
90
- public Vector2i transform (int x , int y ) {
90
+ public Vector2i transform (final int x , final int y ) {
91
91
return new Vector2i (this .transformX (x , y ), this .transformY (x , y ));
92
92
}
93
93
@@ -98,7 +98,7 @@ public Vector2i transform(int x, int y) {
98
98
* @param vector The original vector
99
99
* @return The transformed x coordinate
100
100
*/
101
- public int transformX (Vector2i vector ) {
101
+ public int transformX (final Vector2i vector ) {
102
102
return this .transformX (vector .x (), vector .y ());
103
103
}
104
104
@@ -110,7 +110,7 @@ public int transformX(Vector2i vector) {
110
110
* @param y The y coordinate of the original vector
111
111
* @return The transformed x coordinate
112
112
*/
113
- public int transformX (int x , int y ) {
113
+ public int transformX (final int x , final int y ) {
114
114
return GenericMath .floor (this .matrixRow0 .dot (x , y , 1 ) + GenericMath .FLT_EPSILON );
115
115
}
116
116
@@ -121,7 +121,7 @@ public int transformX(int x, int y) {
121
121
* @param vector The original vector
122
122
* @return The transformed y coordinate
123
123
*/
124
- public int transformY (Vector2i vector ) {
124
+ public int transformY (final Vector2i vector ) {
125
125
return this .transformY (vector .x (), vector .y ());
126
126
}
127
127
@@ -133,7 +133,7 @@ public int transformY(Vector2i vector) {
133
133
* @param y The y coordinate of the original vector
134
134
* @return The transformed y coordinate
135
135
*/
136
- public int transformY (int x , int y ) {
136
+ public int transformY (final int x , final int y ) {
137
137
return GenericMath .floor (this .matrixRow1 .dot (x , y , 1 ) + GenericMath .FLT_EPSILON );
138
138
}
139
139
@@ -154,7 +154,7 @@ public DiscreteTransform2 invert() {
154
154
* @param that The transform to compose with
155
155
* @return The new composed transform
156
156
*/
157
- public DiscreteTransform2 compose (DiscreteTransform2 that ) {
157
+ public DiscreteTransform2 compose (final DiscreteTransform2 that ) {
158
158
return new DiscreteTransform2 (this .matrix .mul (that .matrix ));
159
159
}
160
160
@@ -166,7 +166,7 @@ public DiscreteTransform2 compose(DiscreteTransform2 that) {
166
166
* @param that The transform to compose with
167
167
* @return The new composed transform
168
168
*/
169
- public DiscreteTransform2 andThen (DiscreteTransform2 that ) {
169
+ public DiscreteTransform2 andThen (final DiscreteTransform2 that ) {
170
170
return that .compose (this );
171
171
}
172
172
@@ -176,7 +176,7 @@ public DiscreteTransform2 andThen(DiscreteTransform2 that) {
176
176
* @param vector The translation vector
177
177
* @return The translated transform as a copy
178
178
*/
179
- public DiscreteTransform2 withTranslation (Vector2i vector ) {
179
+ public DiscreteTransform2 withTranslation (final Vector2i vector ) {
180
180
return this .withTranslation (vector .x (), vector .y ());
181
181
}
182
182
@@ -187,7 +187,7 @@ public DiscreteTransform2 withTranslation(Vector2i vector) {
187
187
* @param y The y coordinate of the translation
188
188
* @return The translated transform as a copy
189
189
*/
190
- public DiscreteTransform2 withTranslation (int x , int y ) {
190
+ public DiscreteTransform2 withTranslation (final int x , final int y ) {
191
191
return new DiscreteTransform2 (this .matrix .translate (x , y ));
192
192
}
193
193
@@ -198,7 +198,7 @@ public DiscreteTransform2 withTranslation(int x, int y) {
198
198
* @param a The scale factor
199
199
* @return The scaled transform as a copy
200
200
*/
201
- public DiscreteTransform2 withScale (int a ) {
201
+ public DiscreteTransform2 withScale (final int a ) {
202
202
return this .withScale (a , a );
203
203
}
204
204
@@ -209,7 +209,7 @@ public DiscreteTransform2 withScale(int a) {
209
209
* @param vector The scale vector
210
210
* @return The scaled transform as a copy
211
211
*/
212
- public DiscreteTransform2 withScale (Vector2i vector ) {
212
+ public DiscreteTransform2 withScale (final Vector2i vector ) {
213
213
return this .withScale (vector .x (), vector .y ());
214
214
}
215
215
@@ -221,7 +221,7 @@ public DiscreteTransform2 withScale(Vector2i vector) {
221
221
* @param y The scale factor on y
222
222
* @return The scaled transform as a copy
223
223
*/
224
- public DiscreteTransform2 withScale (int x , int y ) {
224
+ public DiscreteTransform2 withScale (final int x , final int y ) {
225
225
if (x == 0 ) {
226
226
throw new IllegalArgumentException ("x == 0" );
227
227
}
@@ -240,7 +240,7 @@ public DiscreteTransform2 withScale(int x, int y) {
240
240
* @param quarterTurns The number of quarter turns in this rotation
241
241
* @return The rotated transform as a copy
242
242
*/
243
- public DiscreteTransform2 withRotation (int quarterTurns ) {
243
+ public DiscreteTransform2 withRotation (final int quarterTurns ) {
244
244
return new DiscreteTransform2 (this .matrix .rotate (Complexd .fromAngleDeg (quarterTurns * 90 )));
245
245
}
246
246
@@ -257,7 +257,7 @@ public DiscreteTransform2 withRotation(int quarterTurns) {
257
257
* the center
258
258
* @return The rotated transform as a copy
259
259
*/
260
- public DiscreteTransform2 withRotation (int quarterTurns , Vector2i point , boolean tileCorner ) {
260
+ public DiscreteTransform2 withRotation (final int quarterTurns , final Vector2i point , final boolean tileCorner ) {
261
261
Vector2d pointDouble = point .toDouble ();
262
262
if (tileCorner ) {
263
263
pointDouble = pointDouble .add (0.5 , 0.5 );
@@ -283,7 +283,7 @@ public DiscreteTransform2 withRotation(int quarterTurns, Vector2i point, boolean
283
283
* of the center on the y axis
284
284
* @return The rotated transform as a copy
285
285
*/
286
- public DiscreteTransform2 withRotation (int halfTurns , Vector2i point , boolean tileCornerX , boolean tileCornerY ) {
286
+ public DiscreteTransform2 withRotation (final int halfTurns , final Vector2i point , final boolean tileCornerX , final boolean tileCornerY ) {
287
287
Vector2d pointDouble = point .toDouble ();
288
288
if (tileCornerX ) {
289
289
pointDouble = pointDouble .add (0.5 , 0 );
@@ -302,7 +302,7 @@ public DiscreteTransform2 withRotation(int halfTurns, Vector2i point, boolean ti
302
302
* @param transform The transformation to add
303
303
* @return The added transforms as a copy
304
304
*/
305
- public DiscreteTransform2 withTransformation (DiscreteTransform2 transform ) {
305
+ public DiscreteTransform2 withTransformation (final DiscreteTransform2 transform ) {
306
306
return new DiscreteTransform2 (transform .matrix ().mul (this .matrix ()));
307
307
}
308
308
@@ -313,7 +313,7 @@ public DiscreteTransform2 withTransformation(DiscreteTransform2 transform) {
313
313
* @param matrix The matrix to use for the transform
314
314
* @return The new transform, or {@link Optional#empty()}
315
315
*/
316
- public static Optional <DiscreteTransform2 > of (Matrix3d matrix ) {
316
+ public static Optional <DiscreteTransform2 > of (final Matrix3d matrix ) {
317
317
if (Arrays .stream (matrix .toArray ())
318
318
.anyMatch (value -> Math .rint (value ) != value )) {
319
319
return Optional .empty ();
@@ -327,7 +327,7 @@ public static Optional<DiscreteTransform2> of(Matrix3d matrix) {
327
327
* @param vector The translation vector
328
328
* @return The new translation transform
329
329
*/
330
- public static DiscreteTransform2 fromTranslation (Vector2i vector ) {
330
+ public static DiscreteTransform2 fromTranslation (final Vector2i vector ) {
331
331
return DiscreteTransform2 .fromTranslation (vector .x (), vector .y ());
332
332
}
333
333
@@ -338,7 +338,7 @@ public static DiscreteTransform2 fromTranslation(Vector2i vector) {
338
338
* @param y The y coordinate of the translation
339
339
* @return The new translation transform
340
340
*/
341
- public static DiscreteTransform2 fromTranslation (int x , int y ) {
341
+ public static DiscreteTransform2 fromTranslation (final int x , final int y ) {
342
342
return new DiscreteTransform2 (Matrix3d .createTranslation (x , y ));
343
343
}
344
344
@@ -349,7 +349,7 @@ public static DiscreteTransform2 fromTranslation(int x, int y) {
349
349
* @param a The scale factor
350
350
* @return The new scale transform
351
351
*/
352
- public static DiscreteTransform2 fromScale (int a ) {
352
+ public static DiscreteTransform2 fromScale (final int a ) {
353
353
return DiscreteTransform2 .fromScale (a , a );
354
354
}
355
355
@@ -360,7 +360,7 @@ public static DiscreteTransform2 fromScale(int a) {
360
360
* @param vector The scale vector
361
361
* @return The new scale transform
362
362
*/
363
- public static DiscreteTransform2 fromScale (Vector2i vector ) {
363
+ public static DiscreteTransform2 fromScale (final Vector2i vector ) {
364
364
return DiscreteTransform2 .fromScale (vector .x (), vector .y ());
365
365
}
366
366
@@ -372,7 +372,7 @@ public static DiscreteTransform2 fromScale(Vector2i vector) {
372
372
* @param y The scale factor on y
373
373
* @return The new scale transform
374
374
*/
375
- public static DiscreteTransform2 fromScale (int x , int y ) {
375
+ public static DiscreteTransform2 fromScale (final int x , final int y ) {
376
376
if (x == 0 ) {
377
377
throw new IllegalArgumentException ("x == 0" );
378
378
}
@@ -391,7 +391,7 @@ public static DiscreteTransform2 fromScale(int x, int y) {
391
391
* @param quarterTurns The number of quarter turns in this rotation
392
392
* @return The new rotation transform
393
393
*/
394
- public static DiscreteTransform2 fromRotation (int quarterTurns ) {
394
+ public static DiscreteTransform2 fromRotation (final int quarterTurns ) {
395
395
return new DiscreteTransform2 (Matrix3d .createRotation (Complexd .fromAngleDeg (quarterTurns * 90 )));
396
396
}
397
397
@@ -407,7 +407,7 @@ public static DiscreteTransform2 fromRotation(int quarterTurns) {
407
407
* the center
408
408
* @return The new rotation transform
409
409
*/
410
- public static DiscreteTransform2 fromRotation (int quarterTurns , Vector2i point , boolean tileCorner ) {
410
+ public static DiscreteTransform2 fromRotation (final int quarterTurns , final Vector2i point , final boolean tileCorner ) {
411
411
Vector2d pointDouble = point .toDouble ();
412
412
if (tileCorner ) {
413
413
pointDouble = pointDouble .add (0.5 , 0.5 );
@@ -432,7 +432,7 @@ public static DiscreteTransform2 fromRotation(int quarterTurns, Vector2i point,
432
432
* of the center on the y axis
433
433
* @return The new rotation transform
434
434
*/
435
- public static DiscreteTransform2 fromRotation (int halfTurns , Vector2i point , boolean tileCornerX , boolean tileCornerY ) {
435
+ public static DiscreteTransform2 fromRotation (final int halfTurns , final Vector2i point , final boolean tileCornerX , final boolean tileCornerY ) {
436
436
Vector2d pointDouble = point .toDouble ();
437
437
if (tileCornerX ) {
438
438
pointDouble = pointDouble .add (0.5 , 0 );
@@ -454,7 +454,7 @@ public static DiscreteTransform2 fromRotation(int halfTurns, Vector2i point, boo
454
454
* @param size The size of the area to rotate
455
455
* @return The new rotation transform
456
456
*/
457
- public static DiscreteTransform2 rotationAroundCenter (int quarterTurns , Vector2i size ) {
457
+ public static DiscreteTransform2 rotationAroundCenter (final int quarterTurns , final Vector2i size ) {
458
458
if (size .x () <= 0 ) {
459
459
throw new IllegalArgumentException ("The size on x must be positive" );
460
460
}
@@ -464,7 +464,7 @@ public static DiscreteTransform2 rotationAroundCenter(int quarterTurns, Vector2i
464
464
final boolean mul180 = (quarterTurns & 1 ) == 0 ;
465
465
final boolean xEven = (size .x () & 1 ) == 0 ;
466
466
final boolean yEven = (size .y () & 1 ) == 0 ;
467
- if (!mul180 || xEven != yEven ) {
467
+ if (!mul180 && xEven != yEven ) {
468
468
throw new IllegalArgumentException ("The size must have the same parity on all axes for rotations that are "
469
469
+ "not a multiple of 180 degrees" );
470
470
}
0 commit comments