hkl-vector

hkl-vector

Synopsis

                    HklMatrix;
                    HklQuaternion;
                    HklVector;
void                hkl_vector_init                     (HklVector *self,
                                                         double x,
                                                         double y,
                                                         double z);
void                hkl_vector_fprintf                  (FILE *file,
                                                         const HklVector *self);
int                 hkl_vector_cmp                      (const HklVector *self,
                                                         const HklVector *vector);
int                 hkl_vector_is_opposite              (const HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_add_vector               (HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_minus_vector             (HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_div_double               (HklVector *self,
                                                         const double d);
void                hkl_vector_times_double             (HklVector *self,
                                                         const double d);
void                hkl_vector_times_vector             (HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_times_matrix             (HklVector *self,
                                                         const HklMatrix *m);
double              hkl_vector_sum                      (const HklVector *self);
double              hkl_vector_scalar_product           (const HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_vectorial_product        (HklVector *self,
                                                         const HklVector *vector);
double              hkl_vector_angle                    (const HklVector *self,
                                                         const HklVector *vector);
double              hkl_vector_oriented_angle           (const HklVector *self,
                                                         const HklVector *vector,
                                                         const HklVector *ref);
double              hkl_vector_norm2                    (const HklVector *self);
int                 hkl_vector_normalize                (HklVector *self);
int                 hkl_vector_is_colinear              (const HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_randomize                (HklVector *self);
void                hkl_vector_randomize_vector         (HklVector *self,
                                                         const HklVector *vector);
void                hkl_vector_randomize_vector_vector  (HklVector *self,
                                                         const HklVector *vector1,
                                                         const HklVector *vector2);
void                hkl_vector_rotated_around_vector    (HklVector *self,
                                                         const HklVector *axe,
                                                         double angle);
void                hkl_vector_rotated_quaternion       (HklVector *self,
                                                         const HklQuaternion *qr);
int                 hkl_vector_is_null                  (const HklVector *self);
void                hkl_vector_project_on_plan          (HklVector *self,
                                                         const HklVector *plan);

Description

Details

HklMatrix

typedef struct {
	double data[3][3];
} HklMatrix;


HklQuaternion

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


HklVector

typedef struct {
	double data[3];
} HklVector;


hkl_vector_init ()

void                hkl_vector_init                     (HklVector *self,
                                                         double x,
                                                         double y,
                                                         double z);

initialize an HklVector

self :

the HklVector to initialize.

x :

the first coordinate value

y :

the second coordinate value

z :

the third coordinate value

hkl_vector_fprintf ()

void                hkl_vector_fprintf                  (FILE *file,
                                                         const HklVector *self);

print an HklVector into a stream

file :

the stream to print into

self :

the HklVector to print.

hkl_vector_cmp ()

int                 hkl_vector_cmp                      (const HklVector *self,
                                                         const HklVector *vector);

compare two HklVector. this comparison use HKL_EPSILON to do the comparison.

self :

the first vector

vector :

th vector to compare with

Returns :

HKL_FALSE if both are equals, HKL_TRUE otherwise.

hkl_vector_is_opposite ()

int                 hkl_vector_is_opposite              (const HklVector *self,
                                                         const HklVector *vector);

self :

vector :

Returns :


hkl_vector_add_vector ()

void                hkl_vector_add_vector               (HklVector *self,
                                                         const HklVector *vector);

add an HklVector to another one.

self :

the modified HklVector

vector :

the hklvector to add

hkl_vector_minus_vector ()

void                hkl_vector_minus_vector             (HklVector *self,
                                                         const HklVector *vector);

substract an HklVector to another one.

self :

the modified HklVector

vector :

the hklvector to substract

hkl_vector_div_double ()

void                hkl_vector_div_double               (HklVector *self,
                                                         const double d);

divide an HklVector by constant.

self :

the HklVector to divide.

d :

constant use to divide the HklVector

hkl_vector_times_double ()

void                hkl_vector_times_double             (HklVector *self,
                                                         const double d);

multiply an HklVector by a constant value.

self :

the HklVector to modify

d :

the multiply factor

hkl_vector_times_vector ()

void                hkl_vector_times_vector             (HklVector *self,
                                                         const HklVector *vector);

multiply an HklVector by another one. This method multiply coordinate by coordinate.

self :

the HklVector to modify

vector :

the HklVector use to modify the first one

hkl_vector_times_matrix ()

void                hkl_vector_times_matrix             (HklVector *self,
                                                         const HklMatrix *m);

self :

m :


hkl_vector_sum ()

double              hkl_vector_sum                      (const HklVector *self);

compute the HklVector sum of all its elements.

self :

the HklVector to sum.

Returns :

the sum of all elements.

hkl_vector_scalar_product ()

double              hkl_vector_scalar_product           (const HklVector *self,
                                                         const HklVector *vector);

compute the scalar product of two HklVector

self :

the first HklVector

vector :

the second HklVector

Returns :

the scalar product.

hkl_vector_vectorial_product ()

void                hkl_vector_vectorial_product        (HklVector *self,
                                                         const HklVector *vector);

compute the vectorial product of two vectors

self :

the first HklVector (modify)

vector :

the second HklVector

hkl_vector_angle ()

double              hkl_vector_angle                    (const HklVector *self,
                                                         const HklVector *vector);

compute the angles beetween two HklVector

self :

the fist HklVector

vector :

the second HklVector

Returns :

the return value is in beetween [0, pi]

hkl_vector_oriented_angle ()

double              hkl_vector_oriented_angle           (const HklVector *self,
                                                         const HklVector *vector,
                                                         const HklVector *ref);

compute the angles beetween two HklVector and use a reference HklVector to orientate the space. That's way the return value can be in beetween [-pi, pi]. the (self, vector, ref) is a right oriented base.

self :

the first HklVector

vector :

the second HklVector

ref :

the reference HklVector

Returns :

the angles [-pi, pi]

hkl_vector_norm2 ()

double              hkl_vector_norm2                    (const HklVector *self);

compute the norm2 of an HklVector

self :

the hklvector use to compute the norm2

Returns :

the sqrt(|v|)

hkl_vector_normalize ()

int                 hkl_vector_normalize                (HklVector *self);

normalize a hkl_vector

self :

the HklVector to normalize

Returns :

HKL_TRUE if the HklVector can be normalized, HKL_FALSE otherwise

hkl_vector_is_colinear ()

int                 hkl_vector_is_colinear              (const HklVector *self,
                                                         const HklVector *vector);

check if two HklVector are colinears

self :

the first HklVector

vector :

the second HklVector

Returns :

HKL_TRUE if both are colinear.

hkl_vector_randomize ()

void                hkl_vector_randomize                (HklVector *self);

initialize a vector with random values. coordinates range [-1, 1]

self :

the HklVector to randomize

hkl_vector_randomize_vector ()

void                hkl_vector_randomize_vector         (HklVector *self,
                                                         const HklVector *vector);

randomize an HklVector an be sure that it is not equal to the HklVector vector.

self :

the HklVector to randomize

vector :

the HklVector result to avoid

hkl_vector_randomize_vector_vector ()

void                hkl_vector_randomize_vector_vector  (HklVector *self,
                                                         const HklVector *vector1,
                                                         const HklVector *vector2);

randomize an HklVector an be sure that it is not equal to the HklVector vector1 and vector2.

self :

the HklVector to randomize

vector1 :

the first HklVector solution to avoid

vector2 :

the second HklVector solution to avoid

hkl_vector_rotated_around_vector ()

void                hkl_vector_rotated_around_vector    (HklVector *self,
                                                         const HklVector *axe,
                                                         double angle);

rotate a vector around another one with a given angle.

self :

the HklVector to rotate

axe :

the axe of rotation

angle :

the angle of the rotation

hkl_vector_rotated_quaternion ()

void                hkl_vector_rotated_quaternion       (HklVector *self,
                                                         const HklQuaternion *qr);

rotate an HklVector using an HklQuaternion.

self :

the HklVector to rotate

qr :

the HklQuaternion use to rotate the vector

hkl_vector_is_null ()

int                 hkl_vector_is_null                  (const HklVector *self);

check if all the coordinates of an HklVector are null.

self :

the hklvector to check

Returns :

HKl_TRUE if all |elements| are below HKL_EPSILON, HKl_FALSE otherwise Todo: test

hkl_vector_project_on_plan ()

void                hkl_vector_project_on_plan          (HklVector *self,
                                                         const HklVector *plan);

project an HklVector on a plan.

todo test

self :

the vector to project (modify)

plan :

the normal of the plane.