MCPcopy
hub / github.com/CadQuery/cadquery / testPlaneRotateZNormal

Method testPlaneRotateZNormal

tests/test_cadquery.py:330–350  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 """

Callers

nothing calls this directly

Calls 6

rotatedMethod · 0.95
VectorClass · 0.85
PlaneClass · 0.85
normalizedMethod · 0.80
crossMethod · 0.80
toTupleMethod · 0.45

Tested by

no test coverage detected