Created
April 5, 2018 21:56
-
-
Save mzucker/c63714cb2e84a0fd429ef6d58e0a349d to your computer and use it in GitHub Desktop.
help de-Abs me plz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function # still using Python 2.7 | |
import sympy | |
print(sympy.__version__) # displays 1.1.1 | |
# create some symbols for angles | |
p, q, r = sympy.symbols('p, q, r', real=True) | |
# create some symbols for unknown elements of lQ | |
x1, y1, z1 = sympy.symbols('x1, y1, z1') | |
# define vectors we know so far | |
P = sympy.Matrix([0, 0, 1]) | |
lR = sympy.Matrix([1, 0, 0]) | |
lQ = sympy.Matrix([x1, y1, z1]) | |
lQ_equations = [ | |
sympy.Eq(lQ.dot(P), 0), # lQ contains P | |
sympy.Eq(lQ.dot(lR), -sympy.cos(p)), # angle at point P | |
sympy.Eq(lQ.dot(lQ), 1) # lQ is a unit vector | |
] | |
S = sympy.solve(lQ_equations, x1, y1, z1, dict=True, simplify=True) | |
print('found {} solutions for lQ:'.format(len(S))) | |
print('\n'.join([sympy.pretty(sln) for sln in S])) | |
lQ = lQ.subs(S[0]) | |
print('now lQ is {}'.format(lQ)) | |
# displays Matrix([[-cos(p)], [-Abs(sin(p))], [0]]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment