CMath.h
上传用户:hkb425
上传日期:2007-06-16
资源大小:34191k
文件大小:3k
- // CMath.h: interface for the CMath class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_CMATH_H__85CB3FA1_05CE_11D6_812C_5254AB37CDC9__INCLUDED_)
- #define AFX_CMATH_H__85CB3FA1_05CE_11D6_812C_5254AB37CDC9__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "structdef.h"
- #include "math.h"
- class CMath
- {
- public:
- CMath();
- virtual ~CMath();
- //////////判断线段是否与多边形相交 true:相交,false:不相交
- bool IsLineSegmentCutByPolygon(VERTEX v1 ,VERTEX v2,VERTEX* pVertex,int number);
- //////////判断线段是否与3D包围盒相交 true:相交,false:不相交
- bool IsLineSegmentCutBy3DBoundary(VERTEX v1 ,VERTEX v2,BOUNDARY_3D boundary);
- //////////判断线段是否与标准长方形相交 true:相交,false:不相交
- bool IsLineSegmentCutByStardQuad(VERTEX v1 ,VERTEX v2,VERTEX va,VERTEX vb,VERTEX vc,VERTEX vd);
- bool IsLineSegmentCutByStardQuad(VERTEX v1 ,VERTEX v2,VERTEX *pv);
-
- //////////由顶点数组获得平面方程
- PLANE GetPlaneEquation(VERTEX *pVertices,int VerticesNumber);
- //////////由三个顶点获得平面方程
- PLANE GetPlaneEquation(VERTEX v1,VERTEX v2,VERTEX v3);
- //////////获得过两点且与一平面垂直的平面方程
- PLANE GetPlaneEquation(VERTEX v1,VERTEX v2,PLANE plane);
- //////////获得过一点且与两平面都垂直的平面方程
- PLANE GetPlaneEquation(VERTEX vertex,PLANE plane1,PLANE plane2);
- //////////获得直线与平面交点
- VERTEX GetIntersection(VERTEX vertex1,VERTEX vertex2,PLANE plane);
- //////////获得交点的贴图坐标
- TEXCOORD GetIntersectionTexCoord(VERTEX pointA,TEXCOORD texcoordA,VERTEX pointB,TEXCOORD texcoordB, PLANE plane);
- //////////获得空间四边形网格上一点的位置 uPos,vPos为0-1之间的数
- VERTEX GetPositionOnGrid(VERTEX *pQuads,float uPos,float vPos);
- //////////获得两向量的叉积
- NORMAL GetTwoNormalProduct(NORMAL normal1,NORMAL normal2);
- //////////获得向量
- NORMAL GetNormal(VERTEX v1,VERTEX v2,VERTEX v3);
- NORMAL GetNormal(float *v1,float *v2,float *v3);
- //////////获得两点距离
- float GetDistance(VERTEX vertex1,VERTEX vertex2);
- //////////获得点到平面的距离
- float GetDistance(VERTEX point,PLANE plane);
- float GetDistance(VERTEX point,PLANE plane,float PowABC);
- //////////获得两向量夹角余弦
- float GetTwoVectorAngleCosine(NORMAL n1,NORMAL n2);
- float GetTwoVectorAngleCosine(VERTEX v1,VERTEX vCenter,VERTEX v2);
- //////////判断两向量的夹角关系
- int ClassifyTwoNormal(NORMAL n1,NORMAL n2);
- //////////判断两向量的夹角关系
- int ClassifyTwoNormal(VERTEX v1,VERTEX vCenter,VERTEX v2);
- //////////判断点与平面的关系 -1:在平面后,0:在平面上,1:在平面前
- int ClassifyPointPlane(VERTEX point,PLANE plane);
- //////////判断多边形与平面关系 -1:在平面后,0:重合,1:在平面前,2:穿越
- int ClassifyPolygonPlane(PLANE plane,VERTEX *pVertex,int number);
- //////////归一标准化
- NORMAL Normalization(NORMAL normal);
- NORMAL Normalization(double x,double y,double z);
- };
- #endif // !defined(AFX_CMATH_H__85CB3FA1_05CE_11D6_812C_5254AB37CDC9__INCLUDED_)