|
|
@ -13,8 +13,9 @@ |
|
|
|
#define EQ(X,Y,EPS) (ABS((X)-(Y))<EPS)//通过误差去判断,两个数是否相等 |
|
|
|
#define EQ_ZERO(X,EPS) (ABS((X))<EPS) |
|
|
|
#define ARR_ZERO(A, N) memset((A), 0, sizeof(A[0])*(N)) |
|
|
|
#define MIN(x,y) (x)<(y)?(x):(y); |
|
|
|
#define MIN(x,y) (x)<(y)?(x):(y) |
|
|
|
#define SWAP(type, x, y) {type tmp=(x); (x)=(y); (y) = tmp;} |
|
|
|
#define M_PI 3.141592 |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
@ -22,6 +23,7 @@ class GVector3; |
|
|
|
class GVector; |
|
|
|
class GMatrix; |
|
|
|
class GPlane; |
|
|
|
class GQuater; |
|
|
|
typedef GVector3 GPoint3; |
|
|
|
|
|
|
|
class GVector3 { |
|
|
@ -228,6 +230,7 @@ public: |
|
|
|
friend float dist(const GPoint3& q, const GLine& l); |
|
|
|
|
|
|
|
friend bool intersect_line_plane(GPoint3& p, const GLine& l, const GPlane& pi); |
|
|
|
friend bool intersect_line_triangle(GPoint3& p, const GLine& l, const GPoint3& p1, const GPoint3& p2, const GPoint3& p3); |
|
|
|
}; |
|
|
|
|
|
|
|
class GPlane { |
|
|
@ -247,4 +250,20 @@ public: |
|
|
|
friend float dist(const GPlane& pi, const GPoint3& p); |
|
|
|
|
|
|
|
friend bool intersect_line_plane(GPoint3& p, const GLine& l, const GPlane& pi); |
|
|
|
|
|
|
|
friend bool intersect_line_triangle(GPoint3& p, const GLine& l, const GPoint3& p1, const GPoint3& p2, const GPoint3& p3); |
|
|
|
}; |
|
|
|
|
|
|
|
class GQuater { |
|
|
|
private: |
|
|
|
float w, x, y, z; |
|
|
|
public: |
|
|
|
GQuater(float w = 1.0f, float x = 0.0f, float y = 0.0f, float z = 0.0f); |
|
|
|
GQuater(const GQuater& copy); |
|
|
|
GQuater(GVector3 axis, float theta, bool radian = false); |
|
|
|
GQuater& operator=(const GQuater& rhs); |
|
|
|
|
|
|
|
GQuater& operator+=(const GQuater& rhs); |
|
|
|
GQuater& operator-=(const GQuater& rhs); |
|
|
|
GQuater& operator*=(const GQuater& rhs); |
|
|
|
}; |