OSVR-Core
MatrixConventionsC.h
Go to the documentation of this file.
1 
13 /*
14 // Copyright 2015 Sensics, Inc.
15 //
16 // Licensed under the Apache License, Version 2.0 (the "License");
17 // you may not use this file except in compliance with the License.
18 // You may obtain a copy of the License at
19 //
20 // http://www.apache.org/licenses/LICENSE-2.0
21 //
22 // Unless required by applicable law or agreed to in writing, software
23 // distributed under the License is distributed on an "AS IS" BASIS,
24 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 // See the License for the specific language governing permissions and
26 // limitations under the License.
27 */
28 
29 #ifndef INCLUDED_MatrixConventionsC_h_GUID_6FC7A4C6_E6C5_4A96_1C28_C3D21B909681
30 #define INCLUDED_MatrixConventionsC_h_GUID_6FC7A4C6_E6C5_4A96_1C28_C3D21B909681
31 
32 /* Internal Includes */
33 #include <osvr/Util/Export.h>
34 #include <osvr/Util/APIBaseC.h>
35 #include <osvr/Util/StdInt.h>
36 #include <osvr/Util/Pose3C.h>
37 #include <osvr/Util/ReturnCodesC.h>
38 
39 /* Library/third-party includes */
40 /* none */
41 
42 /* Standard includes */
43 /* none */
44 
45 OSVR_EXTERN_C_BEGIN
46 
54 typedef uint16_t OSVR_MatrixConventions;
55 
56 #ifndef OSVR_DOXYGEN_EXTERNAL
57 
60 typedef enum OSVR_MatrixMasks {
61  OSVR_MATRIX_MASK_ROWMAJOR = 0x1,
62  OSVR_MATRIX_MASK_ROWVECTORS = 0x2,
63  OSVR_MATRIX_MASK_LHINPUT = 0x4,
64  OSVR_MATRIX_MASK_UNSIGNEDZ = 0x8
66 #endif
67 
85  OSVR_MATRIX_ROWMAJOR = OSVR_MATRIX_MASK_ROWMAJOR
87 
94 typedef enum OSVR_MatrixVectorFlags {
98  OSVR_MATRIX_ROWVECTORS = OSVR_MATRIX_MASK_ROWVECTORS
100 
107  OSVR_MATRIX_LHINPUT = OSVR_MATRIX_MASK_LHINPUT
108 
110 
119  OSVR_MATRIX_UNSIGNEDZ = OSVR_MATRIX_MASK_UNSIGNEDZ
120 } OSVR_ProjectionMatrixZFlags; /* end of matrix flags group */
122 
123 enum {
128 };
129 
138 OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixd(
139  OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, double *mat);
140 
146 OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixf(
147  OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, float *mat);
150 OSVR_EXTERN_C_END
151 
152 #ifdef __cplusplus
153 
155 inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose,
157  double *mat) {
158  return osvrPose3ToMatrixd(pose, flags, mat);
159 }
160 
163 inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose,
165  float *mat) {
166  return osvrPose3ToMatrixf(pose, flags, mat);
167 }
168 
171 template <typename Scalar>
172 inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const *pose,
174  Scalar mat[OSVR_MATRIX_SIZE]) {
175  return osvrPose3ToMatrix(pose, flags, &(mat[0]));
176 }
179 template <typename Scalar>
180 inline OSVR_ReturnCode osvrPose3ToMatrix(OSVR_Pose3 const &pose,
182  Scalar mat[OSVR_MATRIX_SIZE]) {
183  return osvrPose3ToMatrix(&pose, flags, &(mat[0]));
184 }
185 
186 #endif
187 
190 #endif
Header declaring a type and values for simple C return codes.
Matrix takes vectors from a left-handed coordinate system.
Definition: MatrixConventionsC.h:107
Constant for the number of elements in the matrices we use - 4x4.
Definition: MatrixConventionsC.h:127
OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixf(OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, float *mat)
Set a matrix of floats based on a Pose3.
Definition: MatrixConventionsC.cpp:56
Header wrapping the C99 standard stdint header.
OSVR_MatrixMasks
Bitmasks for testing matrix conventions.
Definition: MatrixConventionsC.h:60
Matrix transforms column vectors (default)
Definition: MatrixConventionsC.h:96
Column-major memory order (default)
Definition: MatrixConventionsC.h:83
uint16_t OSVR_MatrixConventions
Type for passing matrix convention flags.
Definition: MatrixConventionsC.h:54
OSVR_MatrixOrderingFlags
Flag bit controlling output memory order.
Definition: MatrixConventionsC.h:81
Matrix transforms row vectors.
Definition: MatrixConventionsC.h:98
Header providing basic C macros for defining API headers.
Row-major memory order.
Definition: MatrixConventionsC.h:85
Matrix takes vectors from a right-handed coordinate system (default)
Definition: MatrixConventionsC.h:105
OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixd(OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, double *mat)
Set a matrix of doubles based on a Pose3.
Definition: MatrixConventionsC.cpp:51
A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
Definition: Pose3C.h:54
Matrix maps the near and far planes to unsigned Z values (in the range [0, 1])
Definition: MatrixConventionsC.h:119
OSVR_ProjectionMatrixInputFlags
Flag bit to indicate coordinate system input to projection matrix.
Definition: MatrixConventionsC.h:102
OSVR_ProjectionMatrixZFlags
Flag bit to indicate the desired post-projection Z value convention.
Definition: MatrixConventionsC.h:113
Header.
Matrix maps the near and far planes to signed Z values (in the range [-1, 1]) (default) ...
Definition: MatrixConventionsC.h:116
OSVR_MatrixVectorFlags
Flag bit controlling expected input to matrices.
Definition: MatrixConventionsC.h:94