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

Function test_normals

tests/test_shapes.py:193–214  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

191
192
193def test_normals():
194
195 r1 = 10
196 r2 = 1
197
198 t = torus(2 * r1, 2 * r2).faces()
199
200 n1 = t.normalAt((r1, 0, r2))
201 n2 = t.normalAt((r1 + r2, 0))
202
203 assert n1.toTuple() == approx((0, 0, 1))
204 assert n2.toTuple() == approx((1, 0, 0))
205
206 n3, p3 = t.normalAt(0, 0)
207
208 assert n3.toTuple() == approx((1, 0, 0))
209 assert p3.toTuple() == approx((r1 + r2, 0, 0))
210
211 (n4, n5), _ = t.normals((0, 0), (0, pi / 2))
212
213 assert n4.toTuple() == approx((1, 0, 0))
214 assert n5.toTuple() == approx((0, 0, 1))
215
216
217def test_trimming():

Callers

nothing calls this directly

Calls 5

torusFunction · 0.90
normalsMethod · 0.80
facesMethod · 0.45
normalAtMethod · 0.45
toTupleMethod · 0.45

Tested by

no test coverage detected