# Données de la figure « trois axes, trois rotations » : jamais affiché comme extrait.
# Mêmes rotations et mêmes départs que 02-three-axes.py ; le trajet est échantillonné de θ = 0 à θ = 3π/2.
import json

import numpy as np
from common import bloch_vector, rx, ry, rz
from qsim.etape1_un_qubit import ZERO

plus = np.array([1, 1]) / np.sqrt(2)
LABELS = ["0", "π/2", "π", "3π/2"]


def xyz(state):
    return [round(float(v), 3) + 0.0 for v in bloch_vector(state)]


rotations = []
for name, gate, start in [("RX", rx, ZERO), ("RY", ry, ZERO), ("RZ", rz, plus)]:
    rotations.append({
        "gate": name,
        "points": [{"theta": label, "xyz": xyz(gate(k * np.pi / 2) @ start)} for k, label in enumerate(LABELS)],
        "path": [xyz(gate(t) @ start) for t in np.linspace(0, 3 * np.pi / 2, 49)],
    })
print(json.dumps({"rotations": rotations}, ensure_ascii=False))
