cqrlib.h   cqrlib.h 
/* /*
* cqrlib.h * cqrlib.h
* *
* *
* Created by Herbert J. Bernstein on 2/15/09. * Created by Herbert J. Bernstein on 2/15/09.
* Copyright 2009 Herbert J. Bernstein. All rights reserved. * Copyright 2009 Herbert J. Bernstein. All rights reserved.
* *
* Revised, 8 July 2009 for CQR_FAR macro -- HJB
*/ */
/* Work supported in part by NIH NIGMS under grant 1R15GM078077-01 and DOE /* Work supported in part by NIH NIGMS under grant 1R15GM078077-01 and DOE
under grant ER63601-1021466-0009501. Any opinions, findings, and under grant ER63601-1021466-0009501. Any opinions, findings, and
conclusions or recommendations expressed in this material are those of the conclusions or recommendations expressed in this material are those of the
author(s) and do not necessarily reflect the views of the funding agencies . author(s) and do not necessarily reflect the views of the funding agencies .
*/ */
/********************************************************************** /**********************************************************************
* * * *
skipping to change at line 66 skipping to change at line 67
#ifndef CQRLIB_H_INCLUDED #ifndef CQRLIB_H_INCLUDED
#define CQRLIB_H_INCLUDED #define CQRLIB_H_INCLUDED
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
#ifdef CNEARTREE_USE_FAR #ifdef CQR_USE_FAR
#include <malloc.h> #include <malloc.h>
#define FAR __far #define CQR_FAR __far
#define MALLOC _fmalloc #define CQR_MALLOC _fmalloc
#define FREE _ffree #define CQR_FREE _ffree
#define MEMSET _fmemset #define CQR_MEMSET _fmemset
#define MEMMOVE _fmemmove #define CQR_MEMMOVE _fmemmove
#else #else
#include <stdlib.h> #include <stdlib.h>
#define FAR #define CQR_FAR
#define MALLOC malloc #define CQR_MALLOC malloc
#define FREE free #define CQR_FREE free
#define MEMSET memset #define CQR_MEMSET memset
#define MEMMOVE memmove #define CQR_MEMMOVE memmove
#endif #endif
#include <math.h> #include <math.h>
#define CQR_FAILED 4 #define CQR_FAILED 4
#define CQR_NO_MEMORY 2 #define CQR_NO_MEMORY 2
#define CQR_BAD_ARGUMENT 1 #define CQR_BAD_ARGUMENT 1
#define CQR_SUCCESS 0 #define CQR_SUCCESS 0
typedef struct { typedef struct {
double w; double w;
skipping to change at line 141 skipping to change at line 142
#define CQRMInverse(inverseq,q) \ #define CQRMInverse(inverseq,q) \
{ double normsq; \ { double normsq; \
CQRMConjugate(inverseq,q); \ CQRMConjugate(inverseq,q); \
CQRMNormsq(normsq,q); \ CQRMNormsq(normsq,q); \
if (normsq > 0.) { \ if (normsq > 0.) { \
CQRMScalarMultiply(inverserq,1./normsq); \ CQRMScalarMultiply(inverserq,1./normsq); \
} }
/* CQRCreateQuaternion -- create a quaternion = w +ix+jy+kz */ /* CQRCreateQuaternion -- create a quaternion = w +ix+jy+kz */
int CQRCreateQuaternion(CQRQuaternionHandle FAR * quaternion, double w, double x, double y, double z); int CQRCreateQuaternion(CQRQuaternionHandle CQR_FAR * quaternion, doubl e w, double x, double y, double z);
/* CQRCreateEmptyQuaternion -- create a quaternion = 0 +i0+j0+k0 */ /* CQRCreateEmptyQuaternion -- create a quaternion = 0 +i0+j0+k0 */
int CQRCreateEmptyQuaternion(CQRQuaternionHandle FAR * quaternion) ; int CQRCreateEmptyQuaternion(CQRQuaternionHandle CQR_FAR * quaternion) ;
/* CQRFreeQuaternion -- free a quaternion */ /* CQRFreeQuaternion -- free a quaternion */
int CQRFreeQuaternion(CQRQuaternionHandle FAR * quaternion); int CQRFreeQuaternion(CQRQuaternionHandle CQR_FAR * quaternion);
/* CQRSetQuaternion -- create an existing quaternion = w +ix+jy+kz */ /* CQRSetQuaternion -- create an existing quaternion = w +ix+jy+kz */
int CQRSetQuaternion( CQRQuaternionHandle quaternion, double w, double x, double y, double z); int CQRSetQuaternion( CQRQuaternionHandle quaternion, double w, double x, double y, double z);
/* CQRAdd -- add a quaternion (q1) to a quaternion (q2) */ /* CQRAdd -- add a quaternion (q1) to a quaternion (q2) */
int CQRAdd (CQRQuaternionHandle quaternion, CQRQuaternionHandle q1, CQ RQuaternionHandle q2 ); int CQRAdd (CQRQuaternionHandle quaternion, CQRQuaternionHandle q1, CQ RQuaternionHandle q2 );
/* CQRSubtract -- subtract a quaternion (q2) from a quaternion (q1) * / /* CQRSubtract -- subtract a quaternion (q2) from a quaternion (q1) * /
skipping to change at line 193 skipping to change at line 194
/* CQRNormsq -- Form the normsquared of a quaternion */ /* CQRNormsq -- Form the normsquared of a quaternion */
int CQRNormsq (double * normsq, CQRQuaternionHandle quaternion ) ; int CQRNormsq (double * normsq, CQRQuaternionHandle quaternion ) ;
/* CQRInverse -- Form the inverse of a quaternion */ /* CQRInverse -- Form the inverse of a quaternion */
int CQRInverse (CQRQuaternionHandle inversequaternion, CQRQuaternionHan dle quaternion ); int CQRInverse (CQRQuaternionHandle inversequaternion, CQRQuaternionHan dle quaternion );
/* CQRRotateByQuaternion -- Rotate a vector by a Quaternion, w = qvq* * / /* CQRRotateByQuaternion -- Rotate a vector by a Quaternion, w = qvq* * /
int CQRRotateByQuaternion(double FAR * w, CQRQuaternionHandle rotquater nion, double FAR * v); int CQRRotateByQuaternion(double CQR_FAR * w, CQRQuaternionHandle rotqu aternion, double CQR_FAR * v);
/* CQRAxis2Quaternion -- Form the quaternion for a rotation around axis v by angle theta */ /* CQRAxis2Quaternion -- Form the quaternion for a rotation around axis v by angle theta */
int CQRAxis2Quaternion (CQRQuaternionHandle rotquaternion, double FAR * v, double theta); int CQRAxis2Quaternion (CQRQuaternionHandle rotquaternion, double CQR_F AR * v, double theta);
/* CQRMatrix2Quaterion -- Form the quaternion from a 3x3 rotation matri x R */ /* CQRMatrix2Quaterion -- Form the quaternion from a 3x3 rotation matri x R */
int CQRMatrix2Quaternion (CQRQuaternionHandle rotquaternion, double R[3 ][3]); int CQRMatrix2Quaternion (CQRQuaternionHandle rotquaternion, double R[3 ][3]);
/* CQRQuaternion2Matrix -- Form the 3x3 rotation matrix from a quaterni on */ /* CQRQuaternion2Matrix -- Form the 3x3 rotation matrix from a quaterni on */
int CQRQuaternion2Matrix (double R[3][3], CQRQuaternionHandle rotquater nion); int CQRQuaternion2Matrix (double R[3][3], CQRQuaternionHandle rotquater nion);
/* CQRQuaternion2Angles -- Convert a Quaternion into Euler Angles for R z(Ry(Rx))) convention */ /* CQRQuaternion2Angles -- Convert a Quaternion into Euler Angles for R z(Ry(Rx))) convention */
int CQRQuaternion2Angles (double FAR * RotX, double FAR * RotY, double FAR * RotZ, CQRQuaternionHandle rotquaternion); int CQRQuaternion2Angles (double CQR_FAR * RotX, double CQR_FAR * RotY, double CQR_FAR * RotZ, CQRQuaternionHandle rotquaternion);
/* CQRAngles2Quaternion -- Convert Euler Angles for Rz(Ry(Rx))) convent ion into a quaternion */ /* CQRAngles2Quaternion -- Convert Euler Angles for Rz(Ry(Rx))) convent ion into a quaternion */
int CQRAngles2Quaternion (CQRQuaternionHandle rotquaternion, double Rot X, double RotY, double RotZ ); int CQRAngles2Quaternion (CQRQuaternionHandle rotquaternion, double Rot X, double RotY, double RotZ );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
 End of changes. 10 change blocks. 
17 lines changed or deleted 18 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/