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

Method testOffsetPlanes

tests/test_workplanes.py:93–118  ·  view source on GitHub ↗

Tests that a plane offset from the origin works ok too

(self)

Source from the content-addressed store, hash-verified

91 )
92
93 def testOffsetPlanes(self):
94 "Tests that a plane offset from the origin works ok too"
95 p = Plane.XY(origin=(10.0, 10.0, 0))
96
97 self.assertTupleAlmostEquals(
98 (11.0, 11.0, 0.0), p.toWorldCoords((1.0, 1.0)).toTuple(), 2
99 )
100 self.assertTupleAlmostEquals(
101 (2.0, 2.0), p.toLocalCoords(Vector(12.0, 12.0, 0)).toTuple(), 2
102 )
103
104 # TODO test these offsets in the other dimensions too
105 p = Plane.YZ(origin=(0, 2, 2))
106 self.assertTupleAlmostEquals(
107 (0.0, 5.0, 5.0), p.toWorldCoords((3.0, 3.0)).toTuple(), 2
108 )
109 self.assertTupleAlmostEquals(
110 (10, 10.0, 0.0), p.toLocalCoords(Vector(0.0, 12.0, 12.0)).toTuple(), 2
111 )
112
113 p = Plane.XZ(origin=(2, 0, 2))
114 r = p.toWorldCoords((1.0, 1.0)).toTuple()
115 self.assertTupleAlmostEquals((3.0, 0.0, 3.0), r, 2)
116 self.assertTupleAlmostEquals(
117 (10.0, 10.0), p.toLocalCoords(Vector(12.0, 0.0, 12.0)).toTuple(), 2
118 )
119
120 def testXYPlaneBasics(self):
121 p = Plane.named("XY")

Callers

nothing calls this directly

Calls 8

VectorClass · 0.85
XYMethod · 0.80
toWorldCoordsMethod · 0.80
toLocalCoordsMethod · 0.80
YZMethod · 0.80
XZMethod · 0.80
toTupleMethod · 0.45

Tested by

no test coverage detected