Printing (Docstrings)¶
mechanics_printing¶
-
sympy.physics.mechanics.functions.
mechanics_printing
()[source]¶ Sets up interactive printing for mechanics’ derivatives.
The main benefit of this is for printing of time derivatives; instead of displaying as Derivative(f(t),t), it will display f’ This is only actually needed for when derivatives are present and are not in a physics.mechanics object.
Examples
>>> # 2 lines below are for tests to function properly >>> import sys >>> sys.displayhook = sys.__displayhook__ >>> from sympy import Function, Symbol, diff >>> from sympy.physics.mechanics import mechanics_printing >>> f = Function('f') >>> t = Symbol('t') >>> x = Symbol('x') >>> diff(f(t), t) Derivative(f(t), t) >>> mechanics_printing() >>> diff(f(t), t) f' >>> diff(f(x), x) Derivative(f(x), x) >>> # 2 lines below are for tests to function properly >>> import sys >>> sys.displayhook = sys.__displayhook__
mprint¶
-
sympy.physics.mechanics.functions.
mprint
(expr, **settings)[source]¶ Function for printing of expressions generated in mechanics.
Extends SymPy’s StrPrinter; mprint is equivalent to: print sstr() mprint takes the same options as sstr.
Parameters: expr : valid sympy object
SymPy expression to print
settings : args
Same as print for SymPy
Examples
>>> from sympy.physics.mechanics import mprint, dynamicsymbols >>> u1 = dynamicsymbols('u1') >>> print(u1) u1(t) >>> mprint(u1) u1
mpprint¶
-
sympy.physics.mechanics.functions.
mpprint
(expr, **settings)[source]¶ Function for pretty printing of expressions generated in mechanics.
Mainly used for expressions not inside a vector; the output of running scripts and generating equations of motion. Takes the same options as SymPy’s pretty_print(); see that function for more information.
Parameters: expr : valid sympy object
SymPy expression to pretty print
settings : args
Same as pretty print
Examples
Use in the same way as pprint
mlatex¶
-
sympy.physics.mechanics.functions.
mlatex
(expr, **settings)[source]¶ Function for printing latex representation of mechanics objects.
For latex representation of Vectors, Dyadics, and dynamicsymbols. Takes the same options as SymPy’s latex(); see that function for more information;
Parameters: expr : valid sympy object
SymPy expression to represent in LaTeX form
settings : args
Same as latex()
Examples
>>> from sympy.physics.mechanics import mlatex, ReferenceFrame, dynamicsymbols >>> N = ReferenceFrame('N') >>> q1, q2 = dynamicsymbols('q1 q2') >>> q1d, q2d = dynamicsymbols('q1 q2', 1) >>> q1dd, q2dd = dynamicsymbols('q1 q2', 2) >>> mlatex(N.x + N.y) '\\mathbf{\\hat{n}_x} + \\mathbf{\\hat{n}_y}' >>> mlatex(q1 + q2) 'q_{1} + q_{2}' >>> mlatex(q1d) '\\dot{q}_{1}' >>> mlatex(q1 * q2d) 'q_{1} \\dot{q}_{2}' >>> mlatex(q1dd * q1 / q1d) '\\frac{q_{1} \\ddot{q}_{1}}{\\dot{q}_{1}}'