I don't manage to set the range so that the circle isn't cut off. I hope someone can help me.
Edited code:
I want to mirror the point 'V' at the line g.
from sympy import symbols
from sympy.plotting import plot
from sympy.plotting import plot_implicit
from sympy.geometry import Circle
from sympy import solve
import numpy as np
x, y = symbols(['x', 'y'])
g = 4*x-3*y+1
V = np.array([5,2])
n = np.array([4, -3])
abs_n = np.linalg.norm(n)
hnf_g = abs(g/abs_n)
mirrored_V = V - 2*hnf_g.evalf(subs={x:V[0], y:V[1]}) * n/abs_n
y_g = solve(g,y)
p = plot(y_g[0], show=False, xlim=(-10,10), ylim=(-10,10))
p.extend(plot_implicit(Circle(V,1).equation(), var_start_end_x=(x,-10,10), var_start_end_y=(y,-10,10)))
p.extend(plot_implicit(Circle(mirrored_V,1).equation(), var_start_end_x=(x,-10,10), var_start_end_y=(y,-10,10)))
p.show()
New result:
Old:
From the docs for plot_implicit
this can be accomplished this by setting the range as shown in the third example, copied below.
p2 = plot_implicit(Eq(x**2 + y**2, 3), (x, -3, 3), (y, -3, 3))
But this requires an Eq
object, which unfortunately either can't be constructed from a Circle
for these purposes - possibly as the result of a bug which passes a bool
instead of a bool
tuple - or I am missing something. If it is the former then
Eq(Circle(Point(0,0),1).equation())
is insufficient, and you must construct the circle equation explicitly, i.e.
Eq((x - 5)**2 + (y - 2)**2 - 1, 1)
from sympy import symbols
from sympy.plotting import plot
from sympy.plotting import plot_implicit
from sympy.geometry import Circle
from sympy import solve
import numpy as np
x, y = symbols(['x', 'y'])
g = 4*x-3*y+1
V = np.array([5,2])
n = np.array([4, -3])
abs_n = np.linalg.norm(n)
hnf_g = abs(g/abs_n)
mirrored_V = V - 2*hnf_g.evalf(subs={x:V[0], y:V[1]}) * n/abs_n
y_g = solve(g,y)
p = plot(y_g[0], show=False, xlim=(-10,10), ylim=(-10,10))
p.extend(plot_implicit(Eq((x - V[0])**2 + (y - V[1])**2, 1),
(x,-10,10), (y,-10,10), show=False))
p.extend(plot_implicit(Eq((x - mirrored_V[0])**2 + (y - mirrored_V[1])**2, 1),
(x,-10,10), (y,-10,10), show=False))
p.show()