OSVR-Core
Modules | Namespaces | Classes | Macros | Typedefs | Functions | Variables
Math data structures

Basic structures and conversion utilities for common math entites. More...

Modules

 Matrix conventions and bit flags
 

Namespaces

 osvr::util::eigen_interop
 Namespace containing const_map() and map() function implementations/overloads to allow easy interoperation of OSVR types and Eigen types.
 

Classes

struct  OSVR_Pose3
 A structure defining a 3D (6DOF) rigid body pose: translation and rotation. More...
 
struct  OSVR_Quaternion
 A structure defining a quaternion, often a unit quaternion representing 3D rotation. More...
 
struct  OSVR_RadialDistortionParameters
 Parameters for a per-color-component radial distortion shader. More...
 
struct  OSVR_Vec2
 A structure defining a 2D vector, which represents position. More...
 
struct  OSVR_Vec3
 A structure defining a 3D vector, often a position/translation. More...
 

Macros

#define OSVR_QUAT_MEMBER(COMPONENT, INDEX)
 
#define OSVR_VEC_MEMBER(COMPONENT, INDEX)
 
#define OSVR_VEC_MEMBER(COMPONENT, INDEX)
 

Typedefs

typedef struct OSVR_Pose3 OSVR_Pose3
 A structure defining a 3D (6DOF) rigid body pose: translation and rotation.
 
typedef struct OSVR_Quaternion OSVR_Quaternion
 A structure defining a quaternion, often a unit quaternion representing 3D rotation.
 
typedef struct OSVR_RadialDistortionParameters OSVR_RadialDistortionParameters
 Parameters for a per-color-component radial distortion shader.
 
typedef struct OSVR_Vec2 OSVR_Vec2
 A structure defining a 2D vector, which represents position.
 
typedef struct OSVR_Vec3 OSVR_Vec3
 A structure defining a 3D vector, often a position/translation.
 

Functions

Eigen::Map< Eigen::Vector3d > osvr::util::vecMap (OSVR_Vec3 &vec)
 Wrap an OSVR_Vec3 in an Eigen object that allows it to interoperate with Eigen as though it were an Eigen::Vector3d. More...
 
Eigen::Map< const Eigen::Vector3d > osvr::util::vecMap (OSVR_Vec3 const &vec)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. For constant vectors. More...
 
Eigen::Quaterniond osvr::util::fromQuat (OSVR_Quaternion const &q)
 Convert an OSVR_Quaternion to an Eigen::Quaterniond.
 
void osvr::util::toQuat (Eigen::Quaterniond const &src, OSVR_Quaternion &q)
 Convert an Eigen::Quaterniond to a OSVR_Quaternion.
 
Eigen::Isometry3d osvr::util::fromPose (OSVR_Pose3 const &pose)
 Turn an OSVR_Pose3 into an Eigen::Transform. More...
 
void osvr::util::toPose (Eigen::Isometry3d const &xform, OSVR_Pose3 &pose)
 Turn an Eigen::Isometry3d (transform) into an OSVR_Pose3. More...
 
void osvr::util::toPose (Eigen::Matrix4d const &mat, OSVR_Pose3 &pose)
 Turn an Eigen::Matrix4d (transform) into an OSVR_Pose3. More...
 
OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixd (OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, double *mat)
 Set a matrix of doubles based on a Pose3. More...
 
OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixf (OSVR_Pose3 const *pose, OSVR_MatrixConventions flags, float *mat)
 Set a matrix of floats based on a Pose3. More...
 
OSVR_INLINE void osvrPose3SetIdentity (OSVR_Pose3 *pose)
 Set a pose to identity.
 
OSVR_INLINE void osvrQuatSetIdentity (OSVR_Quaternion *q)
 Set a quaternion to the identity rotation.
 
OSVR_INLINE void osvrQuatToQuatlib (q_type dest, OSVR_Quaternion const *src)
 
OSVR_INLINE void osvrQuatFromQuatlib (OSVR_Quaternion *dest, q_type const src)
 
OSVR_INLINE void osvrVec3ToQuatlib (q_vec_type dest, OSVR_Vec3 const *src)
 
OSVR_INLINE void osvrVec3FromQuatlib (OSVR_Vec3 *dest, q_vec_type const src)
 
OSVR_INLINE void osvrPose3ToQuatlib (q_xyz_quat_type *dest, OSVR_Pose3 const *src)
 
OSVR_INLINE void osvrPose3FromQuatlib (OSVR_Pose3 *dest, q_xyz_quat_type const *src)
 
OSVR_INLINE void osvrVec2Zero (OSVR_Vec2 *v)
 Set a Vec2 to the zero vector.
 
OSVR_INLINE void osvrVec3Zero (OSVR_Vec3 *v)
 Set a Vec3 to the zero vector.
 

Variables

OSVR_Vec3 OSVR_RadialDistortionParameters::k1
 Vector of K1 coefficients for the R, G, B channels.
 
OSVR_Vec2 OSVR_RadialDistortionParameters::centerOfProjection
 Center of projection for the radial distortion, relative to the bounds of this surface.
 

Detailed Description

Basic structures and conversion utilities for common math entites.

This is not intended to be a full math library. It is expected that you convert the values in these structures into your own math types. If you do not yet have a math library, Eigen is highly recommended.

Macro Definition Documentation

§ OSVR_QUAT_MEMBER

#define OSVR_QUAT_MEMBER (   COMPONENT,
  INDEX 
)
Value:
\
OSVR_INLINE double osvrQuatGet##COMPONENT(OSVR_Quaternion const *q) { \
return q->data[INDEX]; \
} \ \
OSVR_INLINE void osvrQuatSet##COMPONENT(OSVR_Quaternion *q, double val) { \
q->data[INDEX] = val; \
}
double data[4]
Internal data - direct access not recommended.
Definition: QuaternionC.h:51
A structure defining a quaternion, often a unit quaternion representing 3D rotation.
Definition: QuaternionC.h:49

§ OSVR_VEC_MEMBER [1/2]

#define OSVR_VEC_MEMBER (   COMPONENT,
  INDEX 
)
Value:
\
OSVR_INLINE double osvrVec3Get##COMPONENT(OSVR_Vec3 const *v) { \
return v->data[INDEX]; \
} \ \
OSVR_INLINE void osvrVec3Set##COMPONENT(OSVR_Vec3 *v, double val) { \
v->data[INDEX] = val; \
}
A structure defining a 3D vector, often a position/translation.
Definition: Vec3C.h:48
double data[3]
Internal array data.
Definition: Vec3C.h:50

§ OSVR_VEC_MEMBER [2/2]

#define OSVR_VEC_MEMBER (   COMPONENT,
  INDEX 
)
Value:
\
OSVR_INLINE double osvrVec2Get##COMPONENT(OSVR_Vec2 const *v) { \
return v->data[INDEX]; \
} \ \
OSVR_INLINE void osvrVec2Set##COMPONENT(OSVR_Vec2 *v, double val) { \
v->data[INDEX] = val; \
}
A structure defining a 2D vector, which represents position.
Definition: Vec2C.h:48
double data[2]
Internal array data.
Definition: Vec2C.h:50

Function Documentation

§ fromPose()

Eigen::Isometry3d osvr::util::fromPose ( OSVR_Pose3 const &  pose)
inline

Turn an OSVR_Pose3 into an Eigen::Transform.

Parameters
poseInput pose
Returns
an Eigen::Isometry3d (convertible to an Eigen::Affine3d) 3-dimensional transform object equivalent to pose.

§ osvrPose3ToMatrixd()

OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixd ( OSVR_Pose3 const *  pose,
OSVR_MatrixConventions  flags,
double *  mat 
)

Set a matrix of doubles based on a Pose3.

Parameters
poseThe Pose3 to convert
flagsMemory ordering flag - see Matrix flags
[out]matan array of 16 doubles

§ osvrPose3ToMatrixf()

OSVR_UTIL_EXPORT OSVR_ReturnCode osvrPose3ToMatrixf ( OSVR_Pose3 const *  pose,
OSVR_MatrixConventions  flags,
float *  mat 
)

Set a matrix of floats based on a Pose3.

Parameters
poseThe Pose3 to convert
flagsMemory ordering flag - see Matrix flags
[out]matan array of 16 floats

§ toPose() [1/2]

void osvr::util::toPose ( Eigen::Isometry3d const &  xform,
OSVR_Pose3 pose 
)
inline

Turn an Eigen::Isometry3d (transform) into an OSVR_Pose3.

Parameters
[in]xformInput transform.
[out]poseDestination to set based on xform.

§ toPose() [2/2]

void osvr::util::toPose ( Eigen::Matrix4d const &  mat,
OSVR_Pose3 pose 
)
inline

Turn an Eigen::Matrix4d (transform) into an OSVR_Pose3.

Parameters
[in]matInput transform. Assumed to contain only position and orientation.
[out]poseDestination to set based on xform.

§ vecMap() [1/2]

Eigen::Map<Eigen::Vector3d> osvr::util::vecMap ( OSVR_Vec3 vec)
inline

Wrap an OSVR_Vec3 in an Eigen object that allows it to interoperate with Eigen as though it were an Eigen::Vector3d.

Parameters
vecA vector to wrap
Returns
an Eigen::Map allowing use of the OSVR_Vec3 as an Eigen::Vector3d.

§ vecMap() [2/2]

Eigen::Map<const Eigen::Vector3d> osvr::util::vecMap ( OSVR_Vec3 const &  vec)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. For constant vectors.