hkl-quaternion-private: hkl Reference Manual

## hkl-quaternion-private hkl-quaternion-private |

## Functions

HklQuaternion * | hkl_quaternion_dup ()
void | hkl_quaternion_free ()
void | hkl_quaternion_init ()
void | hkl_quaternion_init_from_vector ()
void | hkl_quaternion_init_from_angle_and_axe ()
void | hkl_quaternion_fprintf ()
int | hkl_quaternion_cmp ()
void | hkl_quaternion_minus_quaternion ()
void | hkl_quaternion_times_quaternion ()
double | hkl_quaternion_norm2 ()
void | hkl_quaternion_conjugate ()
void | hkl_quaternion_to_matrix ()
void | hkl_quaternion_to_angle_and_axe ()

## Description

## Functions

### hkl_quaternion_dup ()

    HklQuaternion *
    hkl_quaternion_dup (const HklQuaternion *self);

[skip]

### hkl_quaternion_free ()

    void
    hkl_quaternion_free (HklQuaternion *self);

[skip]

### hkl_quaternion_init ()

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

initialize the four elements of an HklQuaternion

#### Parameters

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

#### Parameters

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.

#### Parameters

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

#### Parameters

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.

#### Parameters

self | the first HklQuaternion |
q | the second HklQuaternion |

#### Returns

TRUE if both are equal, FALSE otherwise.

### hkl_quaternion_minus_quaternion ()

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

substract two HklQuaternions Todo: test

#### Parameters

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

#### Parameters

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

#### Parameters

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

#### Parameters

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

#### Parameters

self | the HklQuaternion use to compute the HklMatrix |
m | the HklMatrix return. | [out caller-allocates]

### 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

#### Parameters

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. |