libatomprobe
Library for Atom Probe Tomography (APT) computation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
quat.h
Go to the documentation of this file.
1 /*
2  * mathfuncs.h - General mathematic functions header
3  * Copyright (C) 2015, D Haley
4 
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 #ifndef ATOMPROBE_MATHFUNCS_H
19 #define ATOMPROBE_MATHFUNCS_H
20 
21 #include <cmath>
22 #include <limits>
23 #include <iostream>
24 #include <vector>
25 #include <algorithm>
26 
27 #include <gsl/gsl_matrix.h>
28 
30 
31 namespace AtomProbe
32 {
33 
35 typedef struct
36 {
37  float a; //Real component
38  float b;
39  float c;
40  float d;
41 } Quaternion;
42 
43 //TODO: Merge with point3D?
45 typedef struct
46 {
47  float fx;
48  float fy;
49  float fz;
50 } Point3f;
51 
52 //Uses quaternion mathematics to perform a rotation around your favourite axis
53 //IMPORTANT: rotVec must be normalised before passing to this function
54 //failure to do so will have weird results
55 //Note result is stored in point passed as argument
56 //angle is in radians.
57 
58 //Inefficient-sh Point3D version
60 
63 void quat_rot(Point3D &p, const Point3D &r, float angle);
64 
66 
70 void quat_rot(Point3f *point, const Point3f *rotVec, float angle);
71 
73 
77 void quat_rot_array(Point3f *point, unsigned int n, const Point3f *rotVec, float angle);
78 
80 
84 void quat_rot_array(Point3D *point, unsigned int n, const Point3f *rotVec, float angle);
85 
86 
88 
91 void quat_get_rot_quat(const Point3f *rotVec, float angle, Quaternion *rotQuat);
92 
94 
96 void quat_rot_apply_quat(Point3f *point, const Quaternion *rotQuat);
97 
98 
99 #ifdef DEBUG
100 bool testMathfuncs();
101 #endif
102 
103 }
104 #endif
void quat_get_rot_quat(const Point3f *rotVec, float angle, Quaternion *rotQuat)
Compute the quaternion for specified rotation.
Definition: quat.cpp:184
void quat_rot_apply_quat(Point3f *point, const Quaternion *rotQuat)
Use previously generated quats from quat_get_rot_quats to rotate a point.
Definition: quat.cpp:206
A 3D point data class storage.
Definition: point3D.h:39
Data storage structure for points.
Definition: quat.h:45
Data storage structure for quaternions.
Definition: quat.h:35
void quat_rot(Point3D &p, const Point3D &r, float angle)
Rotate a point around a given rotation axis by a specified angle.
Definition: quat.cpp:59
void quat_rot_array(Point3f *point, unsigned int n, const Point3f *rotVec, float angle)
Rotate each point in array of size n around a given vector, with specified angle. ...
Definition: quat.cpp:139