import numpy as np
import sys
sys.path.append('/home/magdalena/.hermes/plugins/iarquiteto-naval-brana/skills/brana-rascunho-2d-interativo/scripts')
from ajustar import declividades, monotona, convexa

# Queremos:
# P = [(0, y0), (x1, y1), (x2, y2), (x3, y3), (24, 0)]
# onde max(y) = 3.60

best = None
for y0 in np.linspace(3.1, 3.4, 7):
    for x1 in [4.0, 5.0, 6.0]:
        for y1 in np.linspace(3.50, 3.58, 5):
            for x2 in [9.0, 10.0, 11.0]:
                for y2 in [3.60]:
                    for x3 in [15.0, 16.0, 17.0]:
                        for y3 in np.linspace(2.4, 2.7, 7):
                            P = [(0, y0), (x1, y1), (x2, y2), (x3, y3), (24, 0.0)]
                            m, c, folga = declividades(P)
                            if monotona(c) and monotona(m):
                                conv, arestas = convexa(P, m)
                                if conv and folga > 0:
                                    best = P
                                    print("ACHOU!", P, "folga:", folga)
                                    break
                        if best: break
                    if best: break
                if best: break
            if best: break
        if best: break
