Skip to content

Instantly share code, notes, and snippets.

@silgon
Last active December 4, 2021 09:47
Show Gist options
  • Save silgon/e73f2c3c7777100a51003b9d27b0f010 to your computer and use it in GitHub Desktop.
Save silgon/e73f2c3c7777100a51003b9d27b0f010 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
n_steps = 50
c, d= np.array([3,3]),np.array([1,2])
a = c-d
b = (np.linalg.norm(c)**2-np.linalg.norm(d)**2)/2
x = np.linspace(0, 4, n_steps)
y = np.linspace(0, 4, n_steps)
X, Y = np.meshgrid(x, y)
Z = np.c_[X.flatten(),Y.flatten()]@a-b
Z = Z.reshape(n_steps,n_steps)
fig = plt.figure(0)
ax = plt.subplot(111)
cs = ax.contour(X,Y,Z,levels=20, colors="#666666")
plt.clabel(cs, inline=1, fontsize=10)
plt.plot(c[0],c[1],"o", label="c")
plt.plot(d[0],d[1],"o", label="d")
plt.legend()
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment