# How to get a state vector from bloch sphere coordinates for 1 qubit?

I need to get a state vector for one qubit from bloch coordinates no matter if there could be many states that describes the same bloch coordinates, and it does not have to be normalized, because the bloch coordinates will not always be in the sphere surface.
If this could be done easy with Cirq or Qiskit better, if not please pseudo code or python will be nice.

if you have Bloch vector co-ordinates as $$\left(\begin{array}{cc} x\\ y\\ z \end{array}\right)$$, then just compute the following system

$$x = \sin\theta \cos\phi\,,$$

$$y = \sin\theta \sin\phi\,,$$

$$z = \cos\theta\,.$$

and obtain $$\theta$$ and $$\phi$$.

$$\left|{\psi}\right\rangle = \cos\frac{\theta}{2}\left|0\right\rangle+ e^{i\phi}\sin\frac{\theta}{2}\left|1\right\rangle\,.$$

So, your state vector in computational basis will be $$\left|{\psi}\right\rangle = \left(\begin{array}{cc} \cos\frac{\theta}{2}\\ e^{i\phi}\sin\frac{\theta}{2} \end{array}\right)\,.$$

Thanks to FDGod, I code it in python like this:

def statefromBloch(b):

all_zeros = not np.any(b)
if all_zeros:
b=np.array([1e-30,1e-30,1e-30])
bn= b / np.linalg.norm(b)

θ=acos(bn[2])

seno = sin(θ)
if (seno == 0): seno=  1e-30

ac = bn[0] / seno

if ac > 1: ac = 1
if ac < -1: ac = -1
ϕ= acos(ac)
if (b[1]<0.): ϕ=-ϕ

svqubit = np.zeros(2,dtype = np.complex128)
svqubit[0] = cos(θ/2)
svqubit[1] = sin(θ/2) *( cos(ϕ)+1j*sin(ϕ))