how to sort vectors according to their rotations in the space

335 Views Asked by At

I have a set of $n$-dimensional vectors $(V_1,V_2,...,V_n)$, all of them start from the same point in the space.
I want to sort them based on their rotation in the space. For a $2$-D case, i can find their angle to the unit vector $u=(1,0)$ in the $4$-quadrant space to sort them out.

But not sure for $n$-D space! It is still possible to calculate their angle to a unit vector $u$ using $\cos^{-1}\left(\frac{\langle u,v\rangle}{\|v\|}\right )$, but then many of them can have same angle to that unit vector, while they are different from each other.

Even for a $2$-D space the above formula is the same for upper and lower parts of the 4-quadrant space!

1

There are 1 best solutions below

0
On

In 2D there is a sign-corrected arctangent (in most mathematical libraries, e.g. c++ or matlab it is called atan2(x,y)). It considers the signs of both arguments, not only the sign of the ratio.

For nD, there is an extension of spherical coordinates, see https://en.wikipedia.org/wiki/N-sphere#Spherical_coordinates