Created
July 31, 2022 23:32
-
-
Save andrezsanchez/cd6c0d8a231da38d417ea854615ec685 to your computer and use it in GitHub Desktop.
Calculating an inverse jacobian matrix
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 sympy import Matrix, symbols, sin, cos, pi | |
r, lat, lng = symbols('r lat lng') | |
sphericalToCartesian = Matrix([r*sin(lat)*cos(lng), r*sin(lat)*sin(lng), r*cos(lat)]) | |
jacobian = sphericalToCartesian.jacobian(Matrix([r, lat, lng])) | |
print(jacobian) | |
inverseJacobian = jacobian.inv() | |
inverseJacobian.simplify() | |
print(inverseJacobian) | |
# Now substitute values for the radius, latitude, and longitude. | |
# print(a.subs([(r, 1), (g, pi/2), (f, pi/2)])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment