Rotation of a plane in a given direction should never alter that direction. This test creates a plane and rotates it a random angle in a given direction. After the rotation, the direction of the resulting plane in the rotation-direction should be constant.
(self)
| 369 | assert plane.origin.toTuple() == origin |
| 370 | |
| 371 | def testPlaneRotateConcatRandom(self): |
| 372 | """ |
| 373 | Rotation of a plane in a given direction should never alter that |
| 374 | direction. |
| 375 | |
| 376 | This test creates a plane and rotates it a random angle in a given |
| 377 | direction. After the rotation, the direction of the resulting plane |
| 378 | in the rotation-direction should be constant. |
| 379 | |
| 380 | The test also checks that the origin is unaltered after all rotations. |
| 381 | """ |
| 382 | origin = (2, -1, 1) |
| 383 | plane = Plane(origin=origin, xDir=(1, 0, 0), normal=(0, 0, 1)) |
| 384 | for _ in range(100): |
| 385 | before = { |
| 386 | 0: plane.xDir.toTuple(), |
| 387 | 1: plane.yDir.toTuple(), |
| 388 | 2: plane.zDir.toTuple(), |
| 389 | } |
| 390 | angle = (random() - 0.5) * 720 |
| 391 | direction = randrange(3) |
| 392 | rotation = [0, 0, 0] |
| 393 | rotation[direction] = angle |
| 394 | plane = plane.rotated(rotation) |
| 395 | after = { |
| 396 | 0: plane.xDir.toTuple(), |
| 397 | 1: plane.yDir.toTuple(), |
| 398 | 2: plane.zDir.toTuple(), |
| 399 | } |
| 400 | assert before[direction] == approx(after[direction]) |
| 401 | assert plane.origin.toTuple() == origin |
| 402 | |
| 403 | def testPlaneNoXDir(self): |
| 404 | """ |