Quantum states can he used to encode the information contained in a directi
on, i.e., in a unit vector. We present the best encoding procedure when the
quantum state is made up of N spins (qubits). We find that the quality of
this optimal procedure, which we quantify in terms of the fidelity, depends
solely on the dimension of the encoding space. We also investigate the use
of spatial rotations on a quantum state, which provide a natural and less
demanding encoding. In this case we prove that the fidelity is directly rel
ated to the largest zeros of the Legendre and Jacobi polynomials. We also d
iscuss our results in terms of the information gain.