Test line projection and plane projection methods of cq.Vector
(self)
| 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) |
nothing calls this directly
no test coverage detected