Skip to content

Instantly share code, notes, and snippets.

@JohnL4
Last active April 22, 2022 15:31
Show Gist options
  • Save JohnL4/dc98b2aa4a0503778b4f47993268cbb5 to your computer and use it in GitHub Desktop.
Save JohnL4/dc98b2aa4a0503778b4f47993268cbb5 to your computer and use it in GitHub Desktop.
Google colab snippets
from sympy import *
# import numpy as np # Doesn't mix super-well w/sympy
from sympy.plotting import plot # According to https://stackoverflow.com/questions/71519021/what-is-the-difference-between-matplotlib-and-sympy-plotting-module,
# sympy.plotting is an abstraction layer over matplotlib, and is preferred for symbolic stuff.
# import matplotlib.pyplot as plt
init_printing()
from sympy.vector import CoordSys3D, Vector, matrix_to_vector as m2v
N = CoordSys3D('N')
t = symbols('t')
def vec3(sym):
v = symbols(f'{sym}:3')
g = globals()
for i in range(3):
g[f'{sym}{i}'] = v[i]
g[f'{sym}'] = v[0]*N.i + v[1]*N.j + v[2]*N.k
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment