# Getting Values From Quaternions

I'm using the Quaternion package:

<< Quaternions


Very simply, I would like to be able to get the individual components of the quaternions by themselves.

My problem is, if I try

Re[FromQuaternion[Quaternion[1,2,3,4]]]


I get

1+Re[3J+4K]


I would like to isolate the components instead. Then I could get

1


... or 2 or 3 or 4. How can I do this?

ALSO

Is it possible to convert quaternions into a vector?

See if this helps...

q = Quaternion[21, 22, 23, 24];
q[]
FromQuaternion[q] // FullForm


Quaternion[21,22,23,24]
22
Plus[Complex[21,22],Times[23,J],Times[24,K]]

Now this...

q[]
FromQuaternion[q][]
Re[FromQuaternion[q][]]
Im[FromQuaternion[q][]]
List @@ q


21
21+22 I
21
22
{21,22,23,24}

   p = FromQuaternion[Quaternion[1, 2, 3, 4]]

p/.List[Complex[a_,b_],Times[c_,J],Times[d_,K]]->{a,b,c,d}


{1,2,3,4}

To convert it to a vector remove a from list. And since the pattern always stays same, rather give it a name, like

  quaternion = List[Complex[a_,b_],Times[c_,J],Times[d_,K]]


and call it as p/.quaternion->{a,b,c,d}

This approach is helpful when you don't know the parameters with which the Quaternion` was created