def matne_expand(m1, m2): if not is_Matrix(m1) and not is_Matrix(m2): return Ne(m1, m2) if not is_Matrix(m1) or not is_Matrix(m2): return true if m1.shape != m2.shape: return true return Or(*[Ne(e1, e2) for e1, e2 in zip(m1, m2)])
def mateq_expand(m1, m2): if not is_Matrix(m1) and not is_Matrix(m2): return Eq(m1, m2) if not is_Matrix(m1) or not is_Matrix(m2): return false if m1.shape != m2.shape: return false return And(*[Eq(e1, e2) for e1, e2 in zip(m1, m2)])
def spexpr2fcexpr(expr): if is_Number(expr): return float(expr.evalf()) elif is_Matrix(expr): if expr.shape == (3, 1): return FreeCAD.Vector(*expr.evalf()) elif expr.shape == (4, 4): return FreeCAD.Matrix(*expr.evalf()) else: TypeError elif isinstance(expr, AffineTransformation): return FreeCAD.Placement(spexpr2fcexpr(augment(m=expr.matrix, v=expr.vector).evalf())) elif isinstance(expr, AffineTransformation): return FreeCAD.Placement(spexpr2fcexpr(augment(m=expr.matrix, v=expr.vector).evalf())) else: raise TypeError
def base_decompose(action1, action2): if is_Matrix(action2): return action1 * action2.inv() else: return action1 / action2