//三維幾何函式庫
#include #define eps 1e-8
#define zero(x) (((x)>0?(x):-(x))eps&&
vlen(xmult(subt(p,s.b),subt(p,s.c)))>eps&&vlen(xmult(subt(p,s.c),subt(p,s.a)))>eps;
} int dot_inplane_ex(point3 p,point3 s1,point3 s2,point3 s3)
int same_side(point3 p1,point3 p2,line3 l)
int same_side(point3 p1,point3 p2,point3 l1,point3 l2)
int opposite_side(point3 p1,point3 p2,line3 l)
int opposite_side(point3 p1,point3 p2,point3 l1,point3 l2)
//判兩點在平面同側,點在平面上返回0
int same_side(point3 p1,point3 p2,plane3 s)
int same_side(point3 p1,point3 p2,point3 s1,point3 s2,point3 s3)
//判兩點在平面異側,點在平面上返回0
int opposite_side(point3 p1,point3 p2,plane3 s)
int opposite_side(point3 p1,point3 p2,point3 s1,point3 s2,point3 s3)
//判兩直線平行
int parallel(line3 u,line3 v)
int parallel(point3 u1,point3 u2,point3 v1,point3 v2)
//判兩平面平行
int parallel(plane3 u,plane3 v)
int parallel(point3 u1,point3 u2,point3 u3,point3 v1,point3 v2,point3 v3)
//判直線與平面平行
int parallel(line3 l,plane3 s)
int parallel(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
//判兩直線垂直
int perpendicular(line3 u,line3 v)
int perpendicular(point3 u1,point3 u2,point3 v1,point3 v2)
//判兩平面垂直
int perpendicular(plane3 u,plane3 v)
int perpendicular(point3 u1,point3 u2,point3 u3,point3 v1,point3 v2,point3 v3)
//判直線與平面平行
int perpendicular(line3 l,plane3 s)
int perpendicular(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
//判兩線段相交,包括端點和部分重合
int intersect_in(line3 u,line3 v)
int intersect_in(point3 u1,point3 u2,point3 v1,point3 v2)
//判兩線段相交,不包括端點和部分重合
int intersect_ex(line3 u,line3 v)
int intersect_ex(point3 u1,point3 u2,point3 v1,point3 v2)
//判線段與空間三角形相交,包括交於邊界和(部分)包含
int intersect_in(line3 l,plane3 s)
int intersect_in(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
//判線段與空間三角形相交,不包括交於邊界和(部分)包含
int intersect_ex(line3 l,plane3 s)
int intersect_ex(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
//計算兩直線交點,注意事先判斷直線是否共面和平行!
//線段交點請另外判線段相交(同時還是要判斷是否平行!)
point3 intersection(line3 u,line3 v)
point3 intersection(point3 u1,point3 u2,point3 v1,point3 v2)
//計算直線與平面交點,注意事先判斷是否平行,並保證三點不共線!
//線段和空間三角形交點請另外判斷
point3 intersection(line3 l,plane3 s)
point3 intersection(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
//計算兩平面交線,注意事先判斷是否平行,並保證三點不共線!
line3 intersection(plane3 u,plane3 v)
line3 intersection(point3 u1,point3 u2,point3 u3,point3 v1,point3 v2,point3 v3)
//點到直線距離
double ptoline(point3 p,line3 l)
double ptoline(point3 p,point3 l1,point3 l2)
//點到平面距離
double ptoplane(point3 p,plane3 s)
double ptoplane(point3 p,point3 s1,point3 s2,point3 s3)
//直線到直線距離
double linetoline(line3 u,line3 v)
double linetoline(point3 u1,point3 u2,point3 v1,point3 v2)
//兩直線夾角cos值
double angle_cos(line3 u,line3 v)
double angle_cos(point3 u1,point3 u2,point3 v1,point3 v2)
//兩平面夾角cos值
double angle_cos(plane3 u,plane3 v)
double angle_cos(point3 u1,point3 u2,point3 u3,point3 v1,point3 v2,point3 v3)
//直線平面夾角sin值
double angle_sin(line3 l,plane3 s)
double angle_sin(point3 l1,point3 l2,point3 s1,point3 s2,point3 s3)
三維計算幾何模版
網上找了乙個三維計算幾何模版,完善了一下,使它能使用了.include include include using namespace std 基礎 const double eps 0.000001 typedef struct point 3d bool operator const point...
三維幾何 基礎
數學上,三維幾何是3維歐式空間幾何的傳統名稱。因為實際上這大致就是我們生活的空間。我們在前面介紹過向量運算,其中很多內容也適合三維幾何,如點 向量 點,向量 向量 向量,點 點沒有定義。首先是輔助巨集的定義 const double eps 1e 10 const double pi acos 1 ...
三維幾何 平面
平面的表示。通常用點法式 p0,n 來描述乙個平面。其中點p0是平面的乙個點,向量n是平面的法向量。每個平面把空間分成了兩個部分,我們可以用點法式表示其中乙個半空間。具體是哪乙個呢?是這個法向量所背離的那乙個 即法向量指向遠離半空間的方向 既然是法向量,n就垂直於平面上的所有直線。換句話說,平面上的...