This is the Simu1b Library version 0.1.0.
Libsimu1b was initially written to simulate the NMR behavior of a 1-spin system under free evolution or radio-frequency pulse action. This is an extension of the very simple Simu1 Library. Libsimu1b is able to compute the matrix that is associated to a rotation of given angle and axis, and to apply it to a vector. It also allows to analyze a rotation matrix to deduce its axis vector and angle value.
This is a C API. The user has to write a C program to use it. A simple executable program named demo can be built from the distribution file. The demo.c file provides an example of libsimu1b use.
Original rotation:
==================
angle: 1.57080
axis: 0.00000 0.00000 1.00000
theta: 0.00000 phi: 0.00000
Rotation matrix:
================
0.00000 -1.00000 0.00000
1.00000 0.00000 0.00000
0.00000 0.00000 1.00000
Reconstructed rotation:
=======================
angle: 1.57080
axis: 0.00000 0.00000 1.00000
theta: 0.00000 phi: 0.00000
The libsimu1b API defines two data types:
Mat33
as double Mat33[3][3]
.
It is used to store the matrix of a rotation in a 3D vector space.
Vec3
as double Vec3[3]
.
It describes a vector of the physical 3D space.
#define GOOD 1
#define BAD 0
#define THR 1.0e-10 ;
#define DEFAULT_FORMAT "%.5f"
#define DEFAULT_COLSEP " "
#define DEFAULT_ROWSEP "\n"
void setZero(double d)
defines under which threshold of its absolute value
a double number can be considered as nul.
Default threshold is THR.
void setFormat(char *doubleformat)
defines the print format for doubles.
Defaut format is DEFAULT_FORMAT.
Used by v3print, m33print and printRotation.
void setColsep(char *colseparator)
defines the character string that separates numbers
for the printing of vectors and matrices.
Default string is DEFAULT_COLSEP.
Used by v3print and m33print.
void setRowsep(char *rowseparator)
defines the character string that separates lines
for the printing matrices.
Default string is DEFAULT_ROWSEP.
Used by m33print.
int normalize3(Vec3 v)
normalizes a Vec3 vector, does nothing if its norm is zero,
returns BAD in this case and GOOD otherwise.
void v3print(Vec3 v)
prints a Vec3 vector according to current format and column separator.
double pscal3(Vec3 v1, Vec3 v2)
returns the scalar product of 2 Vec3 vectors.
void m33print(Mat33 m)
prints a Mat33 matrix according to the current format and separators.
void m33copy(Mat33 dest, Mat33 org)
copies the content of a Mat33 matrix from org to dest.
void putcol3(Mat33 m, Vec3 v, int k)
stores the content of v in the kth column of m.
void getcol3(Mat33 m, Vec3 v, int k)
puts in v the content of the kth column of m.
void putrow3(Mat33 m, Vec3 v, int k)
stores the content of v in the kth row of m.
void getrow3(Mat33 m, Vec3 v, int k)
puts in v the content of the kth row of m.
double m33det(Mat33 m)
returns the determinant of a Mat33 matrix.
void matmin(Mat33 mm, Mat33 m)
stores in mm the matrix of all minors of m.
void matvec(Mat33 m, Vec3 v1, Vec3 v2)
Vec3 v2 is the product of Mat33 m by Vec3 v1.
void matmat(Mat33 m1, Mat33 m2, Mat33 m3)
Mat33 v3 is the product of Mat33 v1 by Mat33 m2.
void printRotation(Vec3 v, double angle)
pretty prints a roration of given angle and axis.
topolar(Vec3 v, double *ptheta, double *pphi)
performs cartesian to polar coordinate conversion.
Returns BAD if the vector is nul and GOOD otherwise.
Theta is 0 when the vector is along the z axis.
void tocart(Vec3 v, double theta, double phi)
performs polar to cartesian coordinate conversion.
Theta is 0 when the vector is along the z axis.
void matrot(Mat33 r, Vec3 axis, double angle)
Computes the matrix of the rotation of given axis and angle.
Angle is in radians.
Returns GOOD if axis is not nul and BAD otherwise
int unmatrot(Mat33 r, Vec3 v, double *pangle)
determines the rotation angle and the axis from rotation matrix m.
Performs checkings and calls unmatrot_nocheck.
Returns GOOD if a solution was found and BAD otherwise.
void unmatrot_nocheck(Mat33 r, Vec3 axis, double *pangle)
determines the rotation angle and the axis from rotation matrix m.
Matrix r must be a rotation matrix.
No checking is performed and results may be unpredictible.
Jean-Marc Nuzillard
jm.nuzillard@univ-reims.fr
March 31^{st} 2006