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

📄 math.h

📁 一个用于智能手机的多媒体库适合S60 WinCE的跨平台开发库
💻 H
📖 第 1 页 / 共 3 页
字号:
 * *Returns the smallest pixel-aligned rectangle completely containing a rectangle *\param r the rectangle to transform *\return the pixel-aligned transformed rectangle*/GF_IRect gf_rect_pixelize(GF_Rect *r);/*! *\brief 2D matrix * *The 2D affine matrix object used by renderers and parsers. The transformation of P(x,y) in P'(X, Y) is: \code	X = m[0]*x + m[1]*y + m[2];	Y = m[3]*x + m[4]*y + m[5]; \endcode*/typedef struct{	Fixed m[6];} GF_Matrix2D;/*!\brief matrix initialization *\hideinitializer * *Inits the matrix to the identity matrix*/#define gf_mx2d_init(_obj) { memset((_obj).m, 0, sizeof(Fixed)*6); (_obj).m[0] = (_obj).m[4] = FIX_ONE; }/*!\brief matrix copy *\hideinitializer * *Copies the matrix _from to the matrix _obj*/#define gf_mx2d_copy(_obj, from) memcpy((_obj).m, (from).m, sizeof(Fixed)*6)/*!\brief matrix identity testing *\hideinitializer * *This macro evaluates to 1 if the matrix _obj is the identity matrix, 0 otherwise*/#define gf_mx2d_is_identity(_obj) ((!(_obj).m[1] && !(_obj).m[2] && !(_obj).m[3] && !(_obj).m[5] && ((_obj).m[0]==FIX_ONE) && ((_obj).m[4]==FIX_ONE)) ? 1 : 0)/*!\brief 2D matrix multiplication * *Multiplies two 2D matrices from*_this *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param from transformation matrix to add*/void gf_mx2d_add_matrix(GF_Matrix2D *_this, GF_Matrix2D *from);/*!\brief 2D matrix pre-multiplication * *Multiplies two 2D matrices _this*from *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param from transformation matrix to add*/void gf_mx2d_pre_multiply(GF_Matrix2D *_this, GF_Matrix2D *from);/*!\brief matrix translating * *Translates a 2D matrix *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param cx horizontal translation *\param cy vertical translation*/void gf_mx2d_add_translation(GF_Matrix2D *_this, Fixed cx, Fixed cy);/*!\brief matrix rotating * *Rotates a 2D matrix *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param cx horizontal rotation center coordinate *\param cy vertical rotation center coordinate *\param angle rotation angle in radians*/void gf_mx2d_add_rotation(GF_Matrix2D *_this, Fixed cx, Fixed cy, Fixed angle);/*!\brief matrix scaling * *Scales a 2D matrix *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param scale_x horizontal scaling factor *\param scale_y vertical scaling factor*/void gf_mx2d_add_scale(GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y);/*!\brief matrix uncentered scaling * *Scales a 2D matrix with a non-centered scale *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param scale_x horizontal scaling factor *\param scale_y vertical scaling factor *\param cx horizontal scaling center coordinate *\param cy vertical scaling center coordinate *\param angle scale orienttion angle in radians*/void gf_mx2d_add_scale_at(GF_Matrix2D *_this, Fixed scale_x, Fixed scale_y, Fixed cx, Fixed cy, Fixed angle);/*!\brief matrix skewing * *Skews a 2D matrix *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param skew_x horizontal skew factor *\param skew_y vertical skew factor*/void gf_mx2d_add_skew(GF_Matrix2D *_this, Fixed skew_x, Fixed skew_y);/*!\brief matrix horizontal skewing * *Skews a 2D matrix horizontally by a given angle *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param angle horizontal skew angle in radians*/void gf_mx2d_add_skew_x(GF_Matrix2D *_this, Fixed angle);/*!\brief matrix vertical skewing * *Skews a 2D matrix vertically by a given angle *\param _this matrix being transformed. Once the function is called, _this contains the result matrix *\param angle vertical skew angle in radians*/void gf_mx2d_add_skew_y(GF_Matrix2D *_this, Fixed angle);/*!\brief matrix inversing * *Inverses a 2D matrix  *\param _this matrix being transformed. Once the function is called, _this contains the result matrix*/void gf_mx2d_inverse(GF_Matrix2D *_this);/*!\brief matrix coordinate transformation * *Applies a 2D matrix transformation to coordinates *\param _this transformation matrix *\param x pointer to horizontal coordinate. Once the function is called, x contains the transformed horizontal coordinate *\param y pointer to vertical coordinate. Once the function is called, y contains the transformed vertical coordinate*/void gf_mx2d_apply_coords(GF_Matrix2D *_this, Fixed *x, Fixed *y);/*!\brief matrix point transformation * *Applies a 2D matrix transformation to a 2D point *\param _this transformation matrix *\param pt pointer to 2D point. Once the function is called, pt contains the transformed point*/void gf_mx2d_apply_point(GF_Matrix2D *_this, GF_Point2D *pt);/*!\brief matrix rectangle transformation * *Applies a 2D matrix transformation to a rectangle, giving the enclosing rectangle of the transformed one *\param _this transformation matrix *\param rc pointer to rectangle. Once the function is called, rc contains the transformed rectangle*/void gf_mx2d_apply_rect(GF_Matrix2D *_this, GF_Rect *rc);/*!\brief matrix decomposition * *Decomposes a 2D matrix M as M=Scale x Rotation x Translation if possible *\param _this transformation matrix *\param scale resulting scale part *\param rotate resulting rotation part *\param translate resulting translation part *\return 0 if matrix cannot be decomposed, 1 otherwise*/Bool gf_mx2d_decompose(GF_Matrix2D *_this, GF_Point2D *scale, Fixed *rotate, GF_Point2D *translate);/*! @} *//*! *\addtogroup math3d_grp math3d *\ingroup math_grp *\brief 3D Mathematics functions * *This section documents mathematic tools for 3D geometry operations *	@{ *//*!\brief 3D point or vector * *The 3D point object is used in all the GPAC framework for both point and vector representation.*/typedef struct __vec3f{	Fixed x;	Fixed y;	Fixed z;} GF_Vec;/*base vector operations are MACROs for faster access*//*!\hideinitializer macro evaluating to 1 if vectors are equal, 0 otherwise*/#define gf_vec_equal(v1, v2) (((v1).x == (v2).x) && ((v1).y == (v2).y) && ((v1).z == (v2).z))/*!\hideinitializer macro reversing a vector v = v*/#define gf_vec_rev(v) { (v).x = -(v).x; (v).y = -(v).y; (v).z = -(v).z; }/*!\hideinitializer macro performing the minus operation res = v1 - v2*/#define gf_vec_diff(res, v1, v2) { (res).x = (v1).x - (v2).x; (res).y = (v1).y - (v2).y; (res).z = (v1).z - (v2).z; }/*!\hideinitializer macro performing the add operation res = v1 + v2*/#define gf_vec_add(res, v1, v2) { (res).x = (v1).x + (v2).x; (res).y = (v1).y + (v2).y; (res).z = (v1).z + (v2).z; }/*! *\brief get 3D vector length * *Gets the length of a 3D vector *\return length of the vector */Fixed gf_vec_len(GF_Vec v);/*! *\brief get 3D vector square length * *Gets the square length of a 3D vector *\return square length of the vector */Fixed gf_vec_lensq(GF_Vec v);/*! *\brief get 3D vector dot product * *Gets the dot product of two vectors *\return dot product of the vectors */Fixed gf_vec_dot(GF_Vec v1, GF_Vec v2);/*! *\brief vector normalization * *Norms the vector, eg make its length equal to \ref FIX_ONE *\param v vector to normalize */void gf_vec_norm(GF_Vec *v);/*! *\brief vector scaling * *Scales a vector by a given amount *\param v vector to scale *\param f scale factor *\return scaled vector */GF_Vec gf_vec_scale(GF_Vec v, Fixed f);/*! *\brief vector cross product * *Gets the cross product of two vectors *\param v1 first vector *\param v2 second vector *\return cross-product vector */GF_Vec gf_vec_cross(GF_Vec v1, GF_Vec v2);/*!\brief 4D vector * *The 4D vector object is used in all the GPAC framework for 4 dimension vectors, VRML Rotations and quaternions representation.*/typedef struct __vec4f{	Fixed x;	Fixed y;	Fixed z;	Fixed q;} GF_Vec4;/*!\brief 3D matrix * *The 3D matrix object used by renderers and parsers. The matrix is oriented like OpenGL matrices (column-major ordering), with  the translation part at the end of the coefficients list. \note Unless specified otherwise, the matrix object is always expected to represent an affine transformation. */typedef struct{	Fixed m[16];} GF_Matrix;/*!\hideinitializer gets the len of a quaternion*/#define gf_quat_len(v) gf_sqrt(gf_mulfix((v).q,(v).q) + gf_mulfix((v).x,(v).x) + gf_mulfix((v).y,(v).y) + gf_mulfix((v).z,(v).z))/*!\hideinitializer normalizes a quaternion*/#define gf_quat_norm(v) { \	Fixed __mag = gf_quat_len(v);	\	(v).x = gf_divfix((v).x, __mag); (v).y = gf_divfix((v).y, __mag); (v).z = gf_divfix((v).z, __mag); (v).q = gf_divfix((v).q, __mag);	\	}	\/*!\brief quaternion to rotation * *Transforms a quaternion to a Rotation, expressed as a 4 dimension vector with x,y,z for axis and q for rotation angle *\param quat the quaternion to transform *\return the rotation value */GF_Vec4 gf_quat_to_rotation(GF_Vec4 *quat);/*!\brief quaternion from rotation * *Transforms a Rotation to a quaternion *\param rot the rotation to transform *\return the quaternion value */GF_Vec4 gf_quat_from_rotation(GF_Vec4 rot);/*!inverses a quaternion*/GF_Vec4 gf_quat_get_inv(GF_Vec4 *quat);/*!\brief quaternion multiplication * *Multiplies two quaternions *\param q1 the first quaternion *\param q2 the second quaternion *\return the resulting quaternion */GF_Vec4 gf_quat_multiply(GF_Vec4 *q1, GF_Vec4 *q2);/*!\brief quaternion vector rotating * *Rotates a vector with a quaternion  *\param quat the quaternion modelizing the rotation *\param vec the vector to rotate *\return the resulting vector */GF_Vec gf_quat_rotate(GF_Vec4 *quat, GF_Vec *vec);/*!\brief quaternion from axis and cos * *Constructs a quaternion from an axis and a cosinus value (shortcut to \ref gf_quat_from_rotation) *\param axis the rotation axis *\param cos_a the rotation cosinus value *\return the resulting quaternion */GF_Vec4 gf_quat_from_axis_cos(GF_Vec axis, Fixed cos_a);/*!\brief quaternion interpolation * *Interpolates two quaternions using spherical linear interpolation *\param q1 the first quaternion *\param q2 the second quaternion *\param frac the fraction of the interpolation, between 0 and \ref FIX_ONE *\return the interpolated quaternion */GF_Vec4 gf_quat_slerp(GF_Vec4 q1, GF_Vec4 q2, Fixed frac);/*!\brief 3D Bounding Box * *The 3D Bounding Box is a 3D Axis-Aligned Bounding Box used to in various tools of the GPAC framework for bounds  estimation of a 3D object. It features an axis-aligned box and a sphere bounding volume for fast intersection tests. */typedef struct{	/*!minimum x, y, and z of the object*/	GF_Vec min_edge;	/*!maximum x, y, and z of the object*/	GF_Vec max_edge;	/*!center of the bounding box.\note this is computed from min_edge and max_edge*/	GF_Vec center;	/*!radius of the bounding sphere for this box.\note this is computed from min_edge and max_edge*/	Fixed radius;	/*!the bbox center and radius are valid*/	Bool is_set;} GF_BBox;/*!updates information of the bounding box based on the edge information*/void gf_bbox_refresh(GF_BBox *b);/*!builds a bounding box from a 2D rectangle*/void gf_bbox_from_rect(GF_BBox *box, GF_Rect *rc);/*!builds a rectangle from a 3D bounding box.\note The z dimension is lost and no projection is performed*/

⌨️ 快捷键说明

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