-
Notifications
You must be signed in to change notification settings - Fork 32
/
ndicapi_math.h
127 lines (105 loc) · 4.29 KB
/
ndicapi_math.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*=======================================================================
Copyright (c) 2000-2005 Atamai, Inc.
Use, modification and redistribution of the software, in source or
binary forms, are permitted provided that the following terms and
conditions are met:
1) Redistribution of the source code, in verbatim or modified
form, must retain the above copyright notice, this license,
the following disclaimer, and any notices that refer to this
license and/or the following disclaimer.
2) Redistribution in binary form must include the above copyright
notice, a copy of this license and the following disclaimer
in the documentation or with other materials provided with the
distribution.
3) Modified copies of the source code must be clearly marked as such,
and must not be misrepresented as verbatim copies of the source code.
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS"
WITHOUT EXPRESSED OR IMPLIED WARRANTY INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. IN NO EVENT SHALL ANY COPYRIGHT HOLDER OR OTHER PARTY WHO MAY
MODIFY AND/OR REDISTRIBUTE THE SOFTWARE UNDER THE TERMS OF THIS LICENSE
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, LOSS OF DATA OR DATA BECOMING INACCURATE
OR LOSS OF PROFIT OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF
THE USE OR INABILITY TO USE THE SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
=======================================================================*/
/*! \file ndicapi_math.h
This file contains some math functions that are useful with the NDICAPI.
*/
#ifndef NDICAPI_MATH_H
#define NDICAPI_MATH_H 1
#include "ndicapiExport.h"
#include <stdarg.h>
/*=====================================================================*/
/*! \defgroup NdicapiMath Mathematical Functions
These are some useful math functions. Note that the matrices are
stored using the OpenGL convention:
\f[
\left(
\begin{array}{cccc}
m[0] & m[4] & m[8] & m[12] \\
m[1] & m[5] & m[9] & m[13] \\
m[2] & m[6] & m[10] & m[14] \\
m[3] & m[7] & m[11] & m[15] \\
\end{array}
\right)
\f]
*/
#ifdef __cplusplus
extern "C" {
#endif
/*! \ingroup NdicapiMath
Find the position and orientation of a tool relative to a
reference tool. This is done by quaternion division.
\param a the original tool transformation
\param b the reference tool transformation
\param c the resulting relative transformation
The pointer \em c can be the same as pointer \em a if you want to do
the division in-place.
*/
ndicapiExport void ndiRelativeTransform(const double a[8], const double b[8], double c[8]);
/*! \ingroup NdicapiMath
Convert a quaternion transformation into a 4x4 float matrix.
*/
ndicapiExport void ndiTransformToMatrixf(const float trans[8], float matrix[16]);
/*! \ingroup NdicapiMath
Convert a quaternion transformation into a 4x4 double matrix.
*/
ndicapiExport void ndiTransformToMatrixfd(const float trans[8], double matrix[16]);
/*! \ingroup NdicapiMath
Convert a quaternion transformation into a 4x4 double matrix.
*/
ndicapiExport void ndiTransformToMatrixd(const double trans[8], double matrix[16]);
/*! \ingroup NdicapiMath
Extract rotation angles from a 4x4 float matrix. The order of the
rotations is:
-# roll around \em x axis
-# pitch around \em y axis
-# yaw around \em z axis
*/
ndicapiExport void ndiAnglesFromMatrixf(float angles[3], const float matrix[16]);
/*! \ingroup NdicapiMath
Extract rotation angles from a 4x4 double matrix. The order of the
rotations is:
-# roll around \em x axis
-# pitch around \em y axis
-# yaw around \em z axis
*/
ndicapiExport void ndiAnglesFromMatrixd(double angles[3], const double matrix[16]);
/*! \ingroup NdicapiMath
Extract position coordinates from a 4x4 float matrix. These have
the same value as the position coordinates in the quaternion
transformation.
*/
ndicapiExport void ndiCoordsFromMatrixf(float coords[3], const float matrix[16]);
/*! \ingroup NdicapiMath
Extract position coordinates from a 4x4 double matrix. These have
the same value as the position coordinates in the quaternion
transformation.
*/
ndicapiExport void ndiCoordsFromMatrixd(double coords[3], const double matrix[16]);
#ifdef __cplusplus
}
#endif
#endif