| CrystFEL Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#include "utils.h" struct quaternion; double quaternion_modulus (struct quaternion q); struct quaternion normalise_quaternion (struct quaternion q); struct quaternion random_quaternion (gsl_rng *rng); int quaternion_valid (struct quaternion q); struct rvec quat_rot (struct rvec q,struct quaternion z);
There is a simple quaternion structure in CrystFEL. At the moment, it is
only used when simulating patterns, as an argument to cell_rotate() to
orient the unit cell.
struct quaternion;
struct quaternion
{
double w
double x
double y
double z
};
A structure representing a quaternion.
double quaternion_modulus (struct quaternion q);
If a quaternion represents a pure rotation, its modulus should be unity.
|
A quaternion
|
Returns : |
the modulus of the given quaternion. |
struct quaternion normalise_quaternion (struct quaternion q);
Rescales the quaternion such that its modulus is unity.
|
A quaternion
|
Returns : |
the normalised version of q
|
struct quaternion random_quaternion (gsl_rng *rng);
|
A GSL random number generator to use |
Returns : |
a randomly generated, normalised, quaternion. |
int quaternion_valid (struct quaternion q);
Checks if the given quaternion is normalised.
This function performs a nasty floating point comparison of the form
(modulus > 0.999) && (modulus < 1.001), and so should not be
relied upon to spot anything other than the most obvious input error.
|
A quaternion
|
Returns : |
1 if the quaternion is normalised, 0 if not. |
struct rvec quat_rot (struct rvec q,struct quaternion z);
Rotates a vector according to a quaternion.
|
A vector (in the form of a "struct rvec") |
|
A quaternion
|
Returns : |
A rotated version of p. |