⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 quat.h

📁 模型冲突检测
💻 H
📖 第 1 页 / 共 2 页
字号:
/* quat/vector conversion	*//* create a quaternion from two vectors that rotates v1 to v2  *   about an axis perpendicular to both */CM_EXTERN_FUNCTION( void q_from_two_vecs, ( q_type destQuat,					    q_vec_type v1, 					    q_vec_type v2 ));/* simple conversion	*/CM_EXTERN_FUNCTION( void q_from_vec, ( q_type destQuat, 				       q_vec_type srcVec ));CM_EXTERN_FUNCTION( void q_to_vec, ( q_vec_type destVec, 				     q_type srcQuat ));/* quaternion/4x4 matrix conversions	*/CM_EXTERN_FUNCTION( void q_from_row_matrix, ( q_type destQuat, 					      q_matrix_type matrix ));CM_EXTERN_FUNCTION( void q_from_col_matrix, ( q_type destQuat, 					      q_matrix_type matrix ));CM_EXTERN_FUNCTION( void q_to_row_matrix, ( q_matrix_type destMatrix, 					    q_type srcQuat ));CM_EXTERN_FUNCTION( void q_to_col_matrix, ( q_matrix_type destMatrix, 					    q_type srcQuat ));/* quat/pphigs conversion   */CM_EXTERN_FUNCTION( void qp_to_matrix, ( Q_MatrixType destMatrix, 					 q_type srcQuat ));CM_EXTERN_FUNCTION( void qp_from_matrix, ( q_type destQuat, 					   Q_MatrixType srcMatrix ));/* quat/ogl conversion */CM_EXTERN_FUNCTION( void q_from_ogl_matrix, ( q_type destQuat,					      qogl_matrix_type matrix ));CM_EXTERN_FUNCTION( void q_to_ogl_matrix, ( qogl_matrix_type matrix,					    q_type srcQuat ));/***************************************************************************** *    strictly vector operations * *****************************************************************************//* prints a vector to stdout  */CM_EXTERN_FUNCTION( void q_vec_print, ( q_vec_type  vec ));/* sets vector equal to 3 values given	*/CM_EXTERN_FUNCTION( void q_set_vec, ( q_vec_type vec, 				      double x, double y, double z ));/* copies srcVec to destVec */CM_EXTERN_FUNCTION( void q_vec_copy, ( q_vec_type destVec, 				       q_vec_type srcVec ));/* adds two vectors */CM_EXTERN_FUNCTION( void q_vec_add, ( q_vec_type destVec, 				      q_vec_type aVec, 				      q_vec_type bVec ));/* destVec = v1 - v2 (v1, v2, destVec need not be distinct storage) */CM_EXTERN_FUNCTION( void q_vec_subtract, ( q_vec_type       destVec, 					   q_vec_type v1, 					   q_vec_type v2 ));/* returns value of dot product of v1 and v2	*/CM_EXTERN_FUNCTION( double q_vec_dot_product, ( q_vec_type v1, 					        q_vec_type v2 ));/* scale a vector  (src and dest need not be distinct) */CM_EXTERN_FUNCTION( void q_vec_scale, ( q_vec_type  	  destVec,				        double  	  scaleFactor,				        q_vec_type  srcVec ));/* negate a vector to point in the opposite direction	*/CM_EXTERN_FUNCTION( void q_vec_invert, ( q_vec_type destVec, 					 q_vec_type srcVec ));/*  normalize a vector  (destVec and srcVec may be the same) */CM_EXTERN_FUNCTION( void q_vec_normalize, ( q_vec_type destVec, 					    q_vec_type srcVec ));/* returns magnitude of vector	*/CM_EXTERN_FUNCTION( double q_vec_magnitude, ( q_vec_type  vec ));/*  returns distance between two points/vectors	*/CM_EXTERN_FUNCTION( double q_vec_distance, ( q_vec_type vec1, 					     q_vec_type vec2 ));/* computes cross product of two vectors:  destVec = aVec X bVec *  	destVec same as aVec or bVec ok */CM_EXTERN_FUNCTION( void q_vec_cross_product, ( q_vec_type       destVec, 					        q_vec_type aVec, 					        q_vec_type bVec ));/* copies PPHIGS 3-vectors */CM_EXTERN_FUNCTION( void qp_vec_copy, ( Q_VectorType destVec, 				        Q_VectorType srcVec ));/* convert PPHIGS srcVec to quatlib destVec */CM_EXTERN_FUNCTION( void qp_pvec_to_vec, ( q_vec_type destVec, 					   Q_VectorType srcVec ));/* convert quatlib srcVec to PPHIGS destVec */CM_EXTERN_FUNCTION( void qp_vec_to_pvec, ( Q_VectorType destVec, 					   q_vec_type srcVec ));/***************************************************************************** *    strictly matrix operations * *****************************************************************************//* q_matrix_copy - copies srcMatrix to destMatrix (both matrices are 4x4)   */CM_EXTERN_FUNCTION( void q_matrix_copy, ( q_matrix_type destMatrix, 					  q_matrix_type srcMatrix ));/* copy dest to src, both PPHIGS matrices   */CM_EXTERN_FUNCTION( void qp_matrix_copy, ( Q_MatrixType destMatrix, 					   Q_MatrixType srcMatrix ));CM_EXTERN_FUNCTION( void qogl_matrix_copy, ( qogl_matrix_type dest,					    qogl_matrix_type src ));/* does a 4x4 matrix multiply (the input matrices are 4x4) and *   	    	  puts the result in a 4x4 matrix.  src == dest ok. */CM_EXTERN_FUNCTION( void q_matrix_mult, ( q_matrix_type resultMatrix,					  q_matrix_type leftMatrix,					  q_matrix_type rightMatrix ));/* multiply two pphigs matrices	(dest = source ok)  */CM_EXTERN_FUNCTION( void qp_matrix_mult, ( Q_MatrixType result, 					   Q_MatrixType A, 					   Q_MatrixType B ));CM_EXTERN_FUNCTION( void qogl_matrix_mult, ( qogl_matrix_type result,					     qogl_matrix_type left,					     qogl_matrix_type right ));/* calc determinant the rotation part of a pphigs matrix	*/CM_EXTERN_FUNCTION( double qp_matrix_3x3_determinant, 		   ( Q_MatrixType mat ));/***************************************************************************** *   q_euler_to_col_matrix - euler angles should be in radians   	computed assuming the order of rotation is: yaw, pitch, roll.       This means the following:        	p' = roll( pitch( yaw(p) ) )	 	 or    	p' = Mr * Mp * My * p    Yaw is rotation about Z axis, pitch is rotation about Y axis, and roll    is rotation about X axis.  In terms of these axes, then, the process is:        	p' = Mx * My * Mz * p     where Mx = the standard Foley and van Dam column matrix for rotation    about the X axis, and similarly for Y and Z.        Thus the calling sequence in terms of X, Y, Z is:        	q_euler_to_col_matrix(destMatrix, zRot, yRot, xRot); * *****************************************************************************/CM_EXTERN_FUNCTION( void q_euler_to_col_matrix, ( q_matrix_type destMatrix,						  double yaw, 						  double pitch, 						  double roll ));/***************************************************************************** *    q_col_matrix_to_euler- convert a column matrix to euler angles         input:    	- vector to hold euler angles	- src column matrix        output:    	- euler angles in radians in the range -pi to pi;	    vec[0] = yaw, vec[1] = pitch, vec[2] = roll	    yaw is rotation about Z axis, pitch is about Y, roll -> X rot.        notes:    	- written by Gary Bishop * *****************************************************************************/CM_EXTERN_FUNCTION( void q_col_matrix_to_euler, ( q_vec_type 	angles,            	    	    	    	    	  q_matrix_type colMatrix ));/* prints 4x4 matrix	*/CM_EXTERN_FUNCTION( void q_print_matrix, ( q_matrix_type matrix ));/* prints PPHIGS 3x4 matrix */CM_EXTERN_FUNCTION( void qp_print_matrix, ( Q_MatrixType matrix ));CM_EXTERN_FUNCTION( void qogl_print_matrix, ( qogl_matrix_type ));/* prints PPHIGS 3x4 matrix to file */CM_EXTERN_FUNCTION( void qp_file_print_matrix, ( FILE 	      *filePtr,    	    	    	    	    	    	 Q_MatrixType matrix ));/* from 4x4 row matrix to PPHIGS 3x4 matrix	*/CM_EXTERN_FUNCTION( void qp_row_to_pmatrix, ( Q_MatrixType          pMatrix,					      q_matrix_type rowMatrix ));/* converts PPHIGS matrix to row matrix	*/CM_EXTERN_FUNCTION( void qp_pmatrix_to_row_matrix, 		   ( q_matrix_type rowMatrix,		     Q_MatrixType pMatrix ));/* inverts a PPHIGS matrix  */CM_EXTERN_FUNCTION( void qp_invert_matrix, ( Q_MatrixType invertedMatrix, 					     Q_MatrixType srcMatrix ));/***************************************************************************** *    xyz_quat routines * *****************************************************************************//* invert a vector/quaternion transformation pair   */CM_EXTERN_FUNCTION( void q_xyz_quat_invert, ( q_xyz_quat_type *destPtr, 					      q_xyz_quat_type *srcPtr ));/* converts a row matrix to an xyz_quat	*/CM_EXTERN_FUNCTION( void q_row_matrix_to_xyz_quat, 		   ( q_xyz_quat_type     *xyzQuatPtr,		     q_matrix_type  rowMatrix ));/* convert an xyz_quat to a row matrix	*/CM_EXTERN_FUNCTION( void q_xyz_quat_to_row_matrix, 		   ( q_matrix_type   rowMatrix,		     q_xyz_quat_type *xyzQuatPtr ));/* converts a pphigs matrix to an xyz_quat	*/CM_EXTERN_FUNCTION( void qp_pmatrix_to_xyz_quat, 		   ( q_xyz_quat_type *xyzQuatPtr,		     Q_MatrixType pMatrix ));/* convert an xyz_quat to a pphigs matrix	*/CM_EXTERN_FUNCTION( void qp_xyz_quat_to_pmatrix, 		   ( Q_MatrixType    	pMatrix,		     q_xyz_quat_type	*xyzQuatPtr ));CM_EXTERN_FUNCTION( void q_ogl_matrix_to_xyz_quat,		    ( q_xyz_quat_type *xyzQuatPtr,		      qogl_matrix_type matrix ));CM_EXTERN_FUNCTION( void q_xyz_quat_to_ogl_matrix,		    ( qogl_matrix_type matrix,		      q_xyz_quat_type *xyzQuatPtr ));/* compose q_xyz_quat_vecs to form a third. *//* C_from_A_ptr may be = to either C_from_B_ptr or B_from_A_ptr (or both) */CM_EXTERN_FUNCTION( void q_xyz_quat_compose, ( q_xyz_quat_type *C_from_A_ptr,                                               q_xyz_quat_type *C_from_B_ptr,                                               q_xyz_quat_type *B_from_A_ptr));/***************************************************************************** *    GL support * *****************************************************************************//* convert from quat to GL 4x4 float row matrix	*/CM_EXTERN_FUNCTION( void  qgl_to_matrix,		   (  qgl_matrix_type 	destMatrix,	    	      q_type  	    	srcQuat ));/* qgl_from_matrix- Convert GL 4x4 row-major rotation matrix to  * unit quaternion. *   	- same as q_from_row_matrix, except basic type is float, not double */CM_EXTERN_FUNCTION( void  qgl_from_matrix,		   (  q_type  	    	destQuat,	    	      qgl_matrix_type 	srcMatrix ));/* print gl-style matrix    */CM_EXTERN_FUNCTION( void  qgl_print_matrix,		   (  qgl_matrix_type 	matrix ));#endif /* Q_INCLUDED */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -