判斷直線相對位置關係 POJ 1269

2021-08-29 04:02:09 字數 950 閱讀 1805

月光林地傳送門

【題目大意】給定n組資料,每一組資料是四個互不相同的點,前兩個點p1,p2表示直線l1,後兩個點q1,q2表示直線l2。

給你p1,p2,q1,q2的座標,判斷l1和l2的關係【平行、重合、相交】,如果相交要把交點座標算出來。

模板題。用叉積判位置。兩個向量a、b如果叉積為0,則平行或重合——把乙個點到另一條直線上兩點的兩個向量叉積一下,若為0則重合,非0就平行。

如果叉積不為0,就套公式求交點。【時空扭曲】

【**】:

#include#includeusing namespace std;

struct point

friend inline point operator +(const point &a,const point &b)

friend inline point operator -(const point &a,const point &b)

friend inline double operator *(const point &a,const point &b)

friend inline point operator *(const point &a,const double &k)

friend inline point operator /(const point &a,const double &k)

friend inline double dot(const point &a,const point &b)

}a,b,c,d;

bool on(const point &x,const point &y,const point &z)

int t;

int main()

puts("none");

} else

} puts("end of output\n");

}

判斷點和直線的位置關係

csharp 判斷點和直線的位置關係 直線上的一點 直線上的另一點 需要判斷的點 private intjudgepointtoline point3d linepnta,point3d linepntb,point3d pntm else if judge 0 else return nresul...

判斷兩條線段的相對位置

判斷兩條線段的相對位置,用int s1表示第一條線段,int s2表示第二條線段,即兩線段兩端點的座標為 s1 0 s1 1 s1 2 s1 3 和 s2 0 s2 1 s2 2 s2 3 如果兩線段沒有交點則返回 no 只有乙個交點則返回 point 多個交點則返回 segment public ...

判斷點相對於直線的狀態 位置

程式如下 判斷點相對於直線的狀態 public int ptinline double dptx,double dpty,double dlinex1,double dliney1,double dlinex2,double dliney2 if dliney1 dliney2 if dlinex1...