@@ -381,12 +381,12 @@ def test_rotate(self):
381
381
assert_array_almost_equal (r90 [1 ].transform (self .single_point ), [1 , 1 , - 1 ])
382
382
assert_array_almost_equal (r90 [2 ].transform (self .single_point ), [- 1 , 1 , 1 ])
383
383
384
- assert_array_almost_equal (r90 [0 ].transform (self .multiple_points ), [
385
- [2 , 0 , 0 ], [0 , 0 , 3 ], [0 , - 4 , 0 ], [5 , 0 , 5 ], [6 , - 6 , 6 ]])
386
- assert_array_almost_equal (r90 [1 ].transform (self .multiple_points ), [
387
- [0 , 0 , - 2 ], [0 , 3 , 0 ], [4 , 0 , 0 ], [0 , 5 , - 5 ], [6 , 6 , - 6 ]])
388
- assert_array_almost_equal (r90 [2 ].transform (self .multiple_points ), [
389
- [0 , 2 , 0 ], [- 3 , 0 , 0 ], [0 , 0 , 4 ], [- 5 , 5 , 0 ], [- 6 , 6 , 6 ]])
384
+ assert_array_almost_equal (r90 [0 ].transform (self .multiple_points ),
385
+ [[ 2 , 0 , 0 ], [0 , 0 , 3 ], [0 , - 4 , 0 ], [5 , 0 , 5 ], [6 , - 6 , 6 ]])
386
+ assert_array_almost_equal (r90 [1 ].transform (self .multiple_points ),
387
+ [[ 0 , 0 , - 2 ], [0 , 3 , 0 ], [4 , 0 , 0 ], [0 , 5 , - 5 ], [6 , 6 , - 6 ]])
388
+ assert_array_almost_equal (r90 [2 ].transform (self .multiple_points ),
389
+ [[ 0 , 2 , 0 ], [- 3 , 0 , 0 ], [0 , 0 , 4 ], [- 5 , 5 , 0 ], [- 6 , 6 , 6 ]])
390
390
391
391
r_pi = [Affine3D ().rotate (np .pi , dim ) for dim in range (3 )]
392
392
r180 = [Affine3D ().rotate_deg (180 , dim ) for dim in range (3 )]
@@ -395,12 +395,12 @@ def test_rotate(self):
395
395
assert_array_almost_equal (r180 [1 ].transform (self .single_point ), [- 1 , 1 , - 1 ])
396
396
assert_array_almost_equal (r180 [2 ].transform (self .single_point ), [- 1 , - 1 , 1 ])
397
397
398
- assert_array_almost_equal (r180 [0 ].transform (self .multiple_points ), [
399
- [2 , 0 , 0 ], [0 , - 3 , 0 ], [0 , 0 , - 4 ], [5 , - 5 , 0 ], [6 , - 6 , - 6 ]])
400
- assert_array_almost_equal (r180 [1 ].transform (self .multiple_points ), [
401
- [- 2 , 0 , 0 ], [0 , 3 , 0 ], [0 , 0 , - 4 ], [- 5 , 5 , 0 ], [- 6 , 6 , - 6 ]])
402
- assert_array_almost_equal (r180 [2 ].transform (self .multiple_points ), [
403
- [- 2 , 0 , 0 ], [0 , - 3 , 0 ], [0 , 0 , 4 ], [- 5 , - 5 , 0 ], [- 6 , - 6 , 6 ]])
398
+ assert_array_almost_equal (r180 [0 ].transform (self .multiple_points ),
399
+ [[ 2 , 0 , 0 ], [0 , - 3 , 0 ], [0 , 0 , - 4 ], [5 , - 5 , 0 ], [6 , - 6 , - 6 ]])
400
+ assert_array_almost_equal (r180 [1 ].transform (self .multiple_points ),
401
+ [[ - 2 , 0 , 0 ], [0 , 3 , 0 ], [0 , 0 , - 4 ], [- 5 , 5 , 0 ], [- 6 , 6 , - 6 ]])
402
+ assert_array_almost_equal (r180 [2 ].transform (self .multiple_points ),
403
+ [[ - 2 , 0 , 0 ], [0 , - 3 , 0 ], [0 , 0 , 4 ], [- 5 , - 5 , 0 ], [- 6 , - 6 , 6 ]])
404
404
405
405
r_pi_3_2 = [Affine3D ().rotate (3 * np .pi / 2 , dim ) for dim in range (3 )]
406
406
r270 = [Affine3D ().rotate_deg (270 , dim ) for dim in range (3 )]
@@ -409,12 +409,12 @@ def test_rotate(self):
409
409
assert_array_almost_equal (r270 [1 ].transform (self .single_point ), [- 1 , 1 , 1 ])
410
410
assert_array_almost_equal (r270 [2 ].transform (self .single_point ), [1 , - 1 , 1 ])
411
411
412
- assert_array_almost_equal (r270 [0 ].transform (self .multiple_points ), [
413
- [2 , 0 , 0 ], [0 , 0 , - 3 ], [0 , 4 , 0 ], [5 , 0 , - 5 ], [6 , 6 , - 6 ]])
414
- assert_array_almost_equal (r270 [1 ].transform (self .multiple_points ), [
415
- [0 , 0 , 2 ], [0 , 3 , 0 ], [- 4 , 0 , 0 ], [0 , 5 , 5 ], [- 6 , 6 , 6 ]])
416
- assert_array_almost_equal (r270 [2 ].transform (self .multiple_points ), [
417
- [0 , - 2 , 0 ], [3 , 0 , 0 ], [0 , 0 , 4 ], [5 , - 5 , 0 ], [6 , - 6 , 6 ]])
412
+ assert_array_almost_equal (r270 [0 ].transform (self .multiple_points ),
413
+ [[ 2 , 0 , 0 ], [0 , 0 , - 3 ], [0 , 4 , 0 ], [5 , 0 , - 5 ], [6 , 6 , - 6 ]])
414
+ assert_array_almost_equal (r270 [1 ].transform (self .multiple_points ),
415
+ [[ 0 , 0 , 2 ], [0 , 3 , 0 ], [- 4 , 0 , 0 ], [0 , 5 , 5 ], [- 6 , 6 , 6 ]])
416
+ assert_array_almost_equal (r270 [2 ].transform (self .multiple_points ),
417
+ [[ 0 , - 2 , 0 ], [3 , 0 , 0 ], [0 , 0 , 4 ], [5 , - 5 , 0 ], [6 , - 6 , 6 ]])
418
418
419
419
for dim in range (3 ):
420
420
assert_array_equal (r_pi_2 [dim ].get_matrix (), r90 [dim ].get_matrix ())
@@ -430,35 +430,35 @@ def test_rotate_around(self):
430
430
for dim in range (3 )]
431
431
r90 = [Affine3D ().rotate_deg_around (* self .pivot , 90 , dim ) for dim in range (3 )]
432
432
433
- assert_array_almost_equal (r90 [0 ].transform (self .multiple_points ), [
434
- [2 , 2 , 0 ], [0 , 2 , 3 ], [0 , - 2 , 0 ], [5 , 2 , 5 ], [6 , - 4 , 6 ]])
435
- assert_array_almost_equal (r90 [1 ].transform (self .multiple_points ), [
436
- [0 , 0 , 0 ], [0 , 3 , 2 ], [4 , 0 , 2 ], [0 , 5 , - 3 ], [6 , 6 , - 4 ]])
437
- assert_array_almost_equal (r90 [2 ].transform (self .multiple_points ), [
438
- [2 , 2 , 0 ], [- 1 , 0 , 0 ], [2 , 0 , 4 ], [- 3 , 5 , 0 ], [- 4 , 6 , 6 ]])
433
+ assert_array_almost_equal (r90 [0 ].transform (self .multiple_points ),
434
+ [[ 2 , 2 , 0 ], [0 , 2 , 3 ], [0 , - 2 , 0 ], [5 , 2 , 5 ], [6 , - 4 , 6 ]])
435
+ assert_array_almost_equal (r90 [1 ].transform (self .multiple_points ),
436
+ [[ 0 , 0 , 0 ], [0 , 3 , 2 ], [4 , 0 , 2 ], [0 , 5 , - 3 ], [6 , 6 , - 4 ]])
437
+ assert_array_almost_equal (r90 [2 ].transform (self .multiple_points ),
438
+ [[ 2 , 2 , 0 ], [- 1 , 0 , 0 ], [2 , 0 , 4 ], [- 3 , 5 , 0 ], [- 4 , 6 , 6 ]])
439
439
440
440
441
441
r_pi = [Affine3D ().rotate_around (* self .pivot , np .pi , dim ) for dim in range (3 )]
442
442
r180 = [Affine3D ().rotate_deg_around (* self .pivot , 180 , dim ) for dim in range (3 )]
443
443
444
- assert_array_almost_equal (r180 [0 ].transform (self .multiple_points ), [
445
- [2 , 2 , 2 ], [0 , - 1 , 2 ], [0 , 2 , - 2 ], [5 , - 3 , 2 ], [6 , - 4 , - 4 ]])
446
- assert_array_almost_equal (r180 [1 ].transform (self .multiple_points ), [
447
- [0 , 0 , 2 ], [2 , 3 , 2 ], [2 , 0 , - 2 ], [- 3 , 5 , 2 ], [- 4 , 6 , - 4 ]])
448
- assert_array_almost_equal (r180 [2 ].transform (self .multiple_points ), [
449
- [0 , 2 , 0 ], [2 , - 1 , 0 ], [2 , 2 , 4 ], [- 3 , - 3 , 0 ], [- 4 , - 4 , 6 ]])
444
+ assert_array_almost_equal (r180 [0 ].transform (self .multiple_points ),
445
+ [[ 2 , 2 , 2 ], [0 , - 1 , 2 ], [0 , 2 , - 2 ], [5 , - 3 , 2 ], [6 , - 4 , - 4 ]])
446
+ assert_array_almost_equal (r180 [1 ].transform (self .multiple_points ),
447
+ [[ 0 , 0 , 2 ], [2 , 3 , 2 ], [2 , 0 , - 2 ], [- 3 , 5 , 2 ], [- 4 , 6 , - 4 ]])
448
+ assert_array_almost_equal (r180 [2 ].transform (self .multiple_points ),
449
+ [[ 0 , 2 , 0 ], [2 , - 1 , 0 ], [2 , 2 , 4 ], [- 3 , - 3 , 0 ], [- 4 , - 4 , 6 ]])
450
450
451
451
452
452
r_pi_3_2 = [Affine3D ().rotate_around (* self .pivot , 3 * np .pi / 2 , dim )
453
453
for dim in range (3 )]
454
454
r270 = [Affine3D ().rotate_deg_around (* self .pivot , 270 , dim ) for dim in range (3 )]
455
455
456
- assert_array_almost_equal (r270 [0 ].transform (self .multiple_points ), [
457
- [2 , 0 , 2 ], [0 , 0 , - 1 ], [0 , 4 , 2 ], [5 , 0 , - 3 ], [6 , 6 , - 4 ]])
458
- assert_array_almost_equal (r270 [1 ].transform (self .multiple_points ), [
459
- [2 , 0 , 2 ], [2 , 3 , 0 ], [- 2 , 0 , 0 ], [2 , 5 , 5 ], [- 4 , 6 , 6 ]])
460
- assert_array_almost_equal (r270 [2 ].transform (self .multiple_points ), [
461
- [0 , 0 , 0 ], [3 , 2 , 0 ], [0 , 2 , 4 ], [5 , - 3 , 0 ], [6 , - 4 , 6 ]])
456
+ assert_array_almost_equal (r270 [0 ].transform (self .multiple_points ),
457
+ [[ 2 , 0 , 2 ], [0 , 0 , - 1 ], [0 , 4 , 2 ], [5 , 0 , - 3 ], [6 , 6 , - 4 ]])
458
+ assert_array_almost_equal (r270 [1 ].transform (self .multiple_points ),
459
+ [[ 2 , 0 , 2 ], [2 , 3 , 0 ], [- 2 , 0 , 0 ], [2 , 5 , 5 ], [- 4 , 6 , 6 ]])
460
+ assert_array_almost_equal (r270 [2 ].transform (self .multiple_points ),
461
+ [[ 0 , 0 , 0 ], [3 , 2 , 0 ], [0 , 2 , 4 ], [5 , - 3 , 0 ], [6 , - 4 , 6 ]])
462
462
463
463
for dim in range (3 ):
464
464
assert_array_almost_equal (r90 [dim ].transform (self .single_point ), [1 , 1 , 1 ])
@@ -472,6 +472,15 @@ def test_rotate_around(self):
472
472
assert_array_almost_equal (
473
473
(r90 [dim ] + r180 [dim ]).get_matrix (), r270 [dim ].get_matrix ())
474
474
475
+ def test_scale (self ):
476
+ sx = Affine3D ().scale (3 , 1 , 1 )
477
+ sy = Affine3D ().scale (1 , - 2 , 1 )
478
+ sz = Affine3D ().scale (1 , 1 , 4 )
479
+ trans = Affine3D ().scale (3 , - 2 , 4 )
480
+ assert_array_equal ((sx + sy + sz ).get_matrix (), trans .get_matrix ())
481
+ assert_array_equal (trans .transform (self .single_point ), [3 , - 2 , 4 ])
482
+ assert_array_equal (trans .transform (self .multiple_points ),
483
+ [[6 , 0 , 0 ], [0 , - 6 , 0 ], [0 , 0 , 16 ], [15 , - 10 , 0 ], [18 , - 12 , 24 ]])
475
484
476
485
def test_non_affine_caching ():
477
486
class AssertingNonAffineTransform (mtransforms .Transform ):
0 commit comments