import numpy as np
import matplotlib.pyplot as plt

def descartes(ax, ran_x, ran_y, ax_title,x_label = "x", y_label = "y"):
    ax.set_xlabel(x_label, fontsize = 12)
    ax.set_ylabel(y_label, fontsize = 12)
    ax.set_xlim(ran_x[0], ran_x[1])
    ax.set_ylim(ran_y[0], ran_y[1])
    ax.set_title(ax_title, fontsize = 14)
    ax.grid()
    ax.axhline(0, color = "black")
    ax.axvline(0, color = "black")

def inner_product(vect1,vect2):
    i1=np.inner(vect1,vect2)
    a1=np.linalg.norm(vect1)
    a2=np.linalg.norm(vect2)
    theta=np.arccos(i1/(a1*a2))
    return theta

fig = plt.figure(figsize = (5, 5))
ax = fig.add_subplot(111)

title1 = "Tokyo University 2024 Math qu.1 NO1"
descartes(ax, [-3,3], [-1, 4],title1)

point_A = np.array([0, -1, 1])

xp,yp=[],[]

for xx in np.linspace(-3,3,200):
    for yy in np.linspace(-3,3,200):
        point_P=np.array([xx,yy,0])
        theta1=inner_product(point_A,point_P)
        point_AP=point_P-point_A
        point_AO=-point_A
        theta2=inner_product(point_AP,point_AO)
        if (theta1 >= 2/3*np.pi) and (theta2 <= np.pi/6):
            xp.append(xx)
            yp.append(yy)

ax.scatter(xp,yp,s=3,color="blue")
plt.show()