hkl-quaternion

hkl-quaternion

Synopsis

                    HklQuaternion;
void                hkl_quaternion_init                 (HklQuaternion *self,
                                                         double a,
                                                         double b,
                                                         double c,
                                                         double d);
void                hkl_quaternion_init_from_vector     (HklQuaternion *self,
                                                         const HklVector *v);
void                hkl_quaternion_init_from_angle_and_axe
                                                        (HklQuaternion *self,
                                                         double angle,
                                                         const HklVector *v);
void                hkl_quaternion_fprintf              (FILE *file,
                                                         const HklQuaternion *self);
int                 hkl_quaternion_cmp                  (const HklQuaternion *self,
                                                         const HklQuaternion *q);
void                hkl_quaternion_minus_quaternion     (HklQuaternion *self,
                                                         const HklQuaternion *q);
void                hkl_quaternion_times_quaternion     (HklQuaternion *self,
                                                         const HklQuaternion *q);
double              hkl_quaternion_norm2                (const HklQuaternion *self);
void                hkl_quaternion_conjugate            (HklQuaternion *self);
void                hkl_quaternion_to_matrix            (const HklQuaternion *self,
                                                         HklMatrix *m);
void                hkl_quaternion_to_angle_and_axe     (const HklQuaternion *self,
                                                         double *angle,
                                                         HklVector *v);

Description

Details

HklQuaternion

typedef struct {
	double data[4];
} HklQuaternion;


hkl_quaternion_init ()

void                hkl_quaternion_init                 (HklQuaternion *self,
                                                         double a,
                                                         double b,
                                                         double c,
                                                         double d);

initialize the four elements of an HklQuaternion

self :

the HklQuaternion to initialize

a :

the 1st element value

b :

the 2nd element value

c :

the 3rd element value

d :

the 4th element value

hkl_quaternion_init_from_vector ()

void                hkl_quaternion_init_from_vector     (HklQuaternion *self,
                                                         const HklVector *v);

initialize an HklQuaternion from an HklVector

self :

the HklQuaternion to set

v :

the HklVector used to set the self HklQuaternion

hkl_quaternion_init_from_angle_and_axe ()

void                hkl_quaternion_init_from_angle_and_axe
                                                        (HklQuaternion *self,
                                                         double angle,
                                                         const HklVector *v);

initialize an HklQuaternion from a vector and a angle.

self :

the HklQuaternion to set

angle :

the angles of the rotation

v :

the axe of rotation

hkl_quaternion_fprintf ()

void                hkl_quaternion_fprintf              (FILE *file,
                                                         const HklQuaternion *self);

print an HklQuaternion into a FILE stream

file :

the file to send the HklQuaternion into

self :

the HklQuaternion to write into the file stream.

hkl_quaternion_cmp ()

int                 hkl_quaternion_cmp                  (const HklQuaternion *self,
                                                         const HklQuaternion *q);

compare two HklQuaternion.

self :

the first HklQuaternion

q :

the second HklQuaternion

Returns :

HKL_TRUE if both are equal, HKL_FAIL otherwise.

hkl_quaternion_minus_quaternion ()

void                hkl_quaternion_minus_quaternion     (HklQuaternion *self,
                                                         const HklQuaternion *q);

substract two HklQuaternions Todo: test

self :

the HklQuaternion to modify.

q :

the HklQuaternion to substract

hkl_quaternion_times_quaternion ()

void                hkl_quaternion_times_quaternion     (HklQuaternion *self,
                                                         const HklQuaternion *q);

multiply two quaternions

self :

the HklQuaternion to modify

q :

the HklQuaternion to multiply by

hkl_quaternion_norm2 ()

double              hkl_quaternion_norm2                (const HklQuaternion *self);

compute the norm2 of an HklQuaternion

self :

the quaternion use to compute the norm

Returns :

the self hklquaternion norm

hkl_quaternion_conjugate ()

void                hkl_quaternion_conjugate            (HklQuaternion *self);

compute the conjugate of a quaternion

self :

the HklQuaternion to conjugate

hkl_quaternion_to_matrix ()

void                hkl_quaternion_to_matrix            (const HklQuaternion *self,
                                                         HklMatrix *m);

Compute the rotation matrix of a Quaternion.

compute the rotation matrix corresponding to the unitary quaternion. \f$ q = a + b \cdot i + c \cdot j + d \cdot k \f$

\f$ \left( \begin{array}{ccc} a^2+b^2-c^2-d^2 & 2bc-2ad & 2ac+2bd\\ 2ad+2bc & a^2-b^2+c^2-d^2 & 2cd-2ab\\ 2bd-2ac & 2ab+2cd & a^2-b^2-c^2+d^2 \end{array} \right) \f$ Todo: optimize

self :

the HklQuaternion use to compute the HklMatrix

m :

the HklMatrix return.

hkl_quaternion_to_angle_and_axe ()

void                hkl_quaternion_to_angle_and_axe     (const HklQuaternion *self,
                                                         double *angle,
                                                         HklVector *v);

compute the axe and angle of the unitary quaternion angle [-pi, pi] if q is the (1, 0, 0, 0) quaternion return the (0,0,0) axe and a 0 angle

self :

The HklQuaternion use to compute the angle and the roation axis.

angle :

the returned angle of the rotation.

v :

the returned axis of the rotation.