Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save oliver-batchelor/b18fdcbc533d205cf1527c7e6770b63a to your computer and use it in GitHub Desktop.
Save oliver-batchelor/b18fdcbc533d205cf1527c7e6770b63a to your computer and use it in GitHub Desktop.
EWA Splatting Jacobian sympy
import sympy as sp
fx, fy, cx, cy, x, y, z = sp.symbols('fx fy cx cy x y z')
K = sp.Matrix([[fx, 0, cx],
[0, fy, cy],
[0, 0, 1]])
p = sp.Matrix([x, y, z])
# project point
p_proj_ = K @ p
d = p_proj_[2]
p_proj = p_proj_ / p_proj_[2]
J = sp.diff(p_proj, p)
J_flat = sp.transpose(J.reshape(3, 3))
print(sp.simplify(J_flat))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment