Base: extend Placement/Rotation API
* Add Placement::isSame() and expose to Python * Add Placement::multRight/Placement::multLeft * Fix PlacementPy::rotate * Add Rotation::multRight/Rotation::multLeft * Add a test feature FeatureTestPlacement for uni tests * Add unit tests
This commit is contained in:
@@ -216,6 +216,29 @@ class PartTestNormals(unittest.TestCase):
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
class PartTestShapeRotate(unittest.TestCase):
|
||||
def testPlacement(self):
|
||||
box = Part.makeBox(1, 1, 1)
|
||||
box.Placement.Base = Base.Vector(10, 10, 10)
|
||||
box.rotate((0, 0, 0), (0, 0, 1), 90)
|
||||
|
||||
p1 = Base.Placement()
|
||||
p1.Base = Base.Vector(10, 10, 10)
|
||||
|
||||
p2 = Base.Placement()
|
||||
p2.Rotation.Angle = math.radians(90)
|
||||
self.assertTrue(box.Placement.isSame(p2 * p1))
|
||||
|
||||
p5 = p1.copy()
|
||||
p5.rotate((0, 0, 0), (0, 0, 1), 90)
|
||||
self.assertTrue(p5.isSame(p1 * p2))
|
||||
self.assertFalse(box.Placement.isSame(p5))
|
||||
|
||||
p5 = p1.copy()
|
||||
p5.rotate((0, 0, 0), (0, 0, 1), 90, True)
|
||||
self.assertTrue(p5.isSame(p2 * p1))
|
||||
self.assertTrue(box.Placement.isSame(p5))
|
||||
|
||||
class PartTestCircle2D(unittest.TestCase):
|
||||
def testValidCircle(self):
|
||||
p1 = App.Base.Vector2d(0.01, 0.01)
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#***************************************************************************/
|
||||
|
||||
import FreeCAD, os, unittest, tempfile, math
|
||||
from FreeCAD import Base
|
||||
|
||||
class ConsoleTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
@@ -381,6 +382,27 @@ class AlgebraTestCase(unittest.TestCase):
|
||||
self.assertFalse(b.intersected(FreeCAD.BoundBox(4,4,4,6,6,6)).isValid(),"Bbox should not intersect with Bbox outside")
|
||||
self.assertEqual(b.intersected(FreeCAD.BoundBox(-2,-2,-2,2,2,2)).Center, b.Center,"Bbox is not a full subset")
|
||||
|
||||
def testMultLeftOrRight(self):
|
||||
doc = FreeCAD.newDocument()
|
||||
obj = doc.addObject("App::FeatureTestPlacement")
|
||||
|
||||
p1 = Base.Placement()
|
||||
p1.Base = Base.Vector(10, 10, 10)
|
||||
|
||||
p2 = Base.Placement()
|
||||
p2.Rotation.Angle = math.radians(90)
|
||||
|
||||
obj.Input1 = p1
|
||||
obj.Input2 = p2
|
||||
doc.recompute()
|
||||
|
||||
self.assertTrue(obj.MultRight.isSame(p1 * p2))
|
||||
self.assertFalse(obj.MultRight.isSame(p2 * p1))
|
||||
self.assertTrue(obj.MultLeft.isSame(p2 * p1))
|
||||
self.assertFalse(obj.MultLeft.isSame(p1 * p2))
|
||||
|
||||
FreeCAD.closeDocument(doc.Name)
|
||||
|
||||
class MatrixTestCase(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.mat = FreeCAD.Matrix()
|
||||
|
||||
Reference in New Issue
Block a user