Rotation of a plane in the Z direction should never alter its normal. This test creates random planes. The plane is rotated a random angle in the Z-direction to verify that the resulting plane maintains the same normal. The test also checks that the random
(self)
| 328 | ) |
| 329 | |
| 330 | def testPlaneRotateZNormal(self): |
| 331 | """ |
| 332 | Rotation of a plane in the Z direction should never alter its normal. |
| 333 | |
| 334 | This test creates random planes. The plane is rotated a random angle in |
| 335 | the Z-direction to verify that the resulting plane maintains the same |
| 336 | normal. |
| 337 | |
| 338 | The test also checks that the random origin is unaltered after |
| 339 | rotation. |
| 340 | """ |
| 341 | for _ in range(100): |
| 342 | angle = (random() - 0.5) * 720 |
| 343 | xdir = Vector(random(), random(), random()).normalized() |
| 344 | rdir = Vector(random(), random(), random()).normalized() |
| 345 | zdir = xdir.cross(rdir).normalized() |
| 346 | origin = (random(), random(), random()) |
| 347 | plane = Plane(origin=origin, xDir=xdir, normal=zdir) |
| 348 | rotated = plane.rotated((0, 0, angle)) |
| 349 | assert rotated.zDir.toTuple() == approx(zdir.toTuple()) |
| 350 | assert rotated.origin.toTuple() == approx(origin) |
| 351 | |
| 352 | def testPlaneRotateConcat(self): |
| 353 | """ |