MCPcopy Index your code
hub / github.com/CadQuery/cadquery / testVectorProject

Method testVectorProject

tests/test_cad_objects.py:333–363  ·  view source on GitHub ↗

Test line projection and plane projection methods of cq.Vector

(self)

Source from the content-addressed store, hash-verified

331 self.assertEqual(a, c)
332
333 def testVectorProject(self):
334 """
335 Test line projection and plane projection methods of cq.Vector
336 """
337 decimal_places = 9
338
339 normal = Vector(1, 2, 3)
340 base = Vector(5, 7, 9)
341 x_dir = Vector(1, 0, 0)
342
343 # test passing Plane object
344 point = Vector(10, 11, 12).projectToPlane(Plane(base, x_dir, normal))
345 self.assertTupleAlmostEquals(
346 point.toTuple(), (59 / 7, 55 / 7, 51 / 7), decimal_places
347 )
348
349 # test line projection
350 vec = Vector(10, 10, 10)
351 line = Vector(3, 4, 5)
352 angle = vec.getAngle(line)
353
354 vecLineProjection = vec.projectToLine(line)
355
356 self.assertTupleAlmostEquals(
357 vecLineProjection.normalized().toTuple(),
358 line.normalized().toTuple(),
359 decimal_places,
360 )
361 self.assertAlmostEqual(
362 vec.Length * math.cos(angle), vecLineProjection.Length, decimal_places
363 )
364
365 def testVectorNotImplemented(self):
366 v = Vector(1, 2, 3)

Callers

nothing calls this directly

Calls 8

getAngleMethod · 0.95
projectToLineMethod · 0.95
normalizedMethod · 0.95
VectorClass · 0.85
PlaneClass · 0.85
projectToPlaneMethod · 0.80
toTupleMethod · 0.45

Tested by

no test coverage detected