Nearest quaternion [SOLVED]

Hello my question may be a litte bit abstarct.
I have vector of 12 ofQuaternion and one extra which can be change.
I have got Dodecahedron and ofQuaternion are in the middle of faces. I give a white cubes to show it

Furthermore i have an extra one red cube to show changeable ofQuaternion

What I would like to do is:

  • get distane from red box to white box( quaternion in fact)
  • result put in vector or array.
  • repeat that to all boxes,
  • sort list( vector or arraydoesn’t matter)
  • change color of the nearest three white box to blue.

I found that about quaternion
http://stackoverflow.com/questions/4917400/nearest-neighbours-using-quaternions

I have problem, I used two of them and no one works as i would like.
I started from the easiest case. Red box is in the top of object. The same rotation like one of white box. When i print out data to console i get.

1.5708|Face|1
1.5708|Face|2
1.87835|Face|3
2.09155|Face|4
2.09704|Face|5
1.89146|Face|6
0|Face|7
0.549779|Face|8
0.819784|Face|9
1.3165|Face|10
1.84974|Face|11
2.3421|Face|12

A litte bit strange because distance to box of face 8-12 are the same…
furthermore when i rotate one axis a red box .

1.5708|Face|1
1.83677|Face|2
1.61809|Face|3
1.92409|Face|4
2.10895|Face|5
2.07525|Face|6
0.523598|Face|7
0.74009|Face|8
1.22883|Face|9
1.76143|Face|10
2.26781|Face|11
2.58524|Face|12

Thanks for any help;) I do not have any idea what can I do now.
//EDIT
I get some more info.
I found Great circle wiki.
furthermore i found that article page 9. .

unit quaternion great circle arc gives a constant speed rotation around a
fixed axis, and can be written C(t) = ((q1(q0)^–1)^t)*q0.

I do not have any idea what does it mean and how implement it…
//EDIT 2
OK I didn’t read carefully, it was simple slerp.

Anyway I search a litte bit and find out that blog

Eventually I opened quaternionLatLongExample…

It is not the most effective but it works ok. Maybe in future someone would be searching something similar

    float testApp::dist(ofQuaternion a ,ofQuaternion b ){
	ofVec3f center= ofVec3f( 0, -120, 0);
	ofVec3f a_rot = a *center;
	ofVec3f b_rot = b *center;
	float dis = a_rot.distance( b_rot );
	return(dis);
}