Skip to content

Commit 2706e2d

Browse files
committed
修改3太比较函数
1 parent 7d7e53c commit 2706e2d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

computationGeometry/planeGeometry.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#define dcmp(x) (fabs(x) < eps? 0:((x) <0?-1:1))
12
struct Point{
23
double x,y;
34
Point(double _x=0,double _y=0):x(_x),y(_y){}

computationGeometry/二维几何.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
## 向量与点的基本算法
55

66
```c++
7-
7+
#define dcmp(x) (fabs(x) < eps? 0:((x) <0?-1:1))
88
struct Point{
99
double x,y;
1010
Point(double _x=0,double _y=0):x(_x),y(_y){}
@@ -33,7 +33,7 @@ double Area2(Point A,Point B,Point C){return Cross(B-A,C-A);}
3333
## 点和直线
3434
3535
```c++
36-
Point GetLineIntersection(Point &P,Vector & v, Point & Q,Vector w){
36+
Point GetLineIntersection(Point P,Vector v, Point Q,Vector w){
3737
//计算交点,当v,w平行时无效
3838
Point u = P-Q;
3939
double t = Cross(v,u) / Cross(v,w);
@@ -45,17 +45,17 @@ double Dis2Line(Point &P,Point & A,Point & B){
4545
Vector u2 = B-A;
4646
return abs(Cross(u1,u2)/Length(u2));
4747
}
48-
Point GetLineProjection(Point &P,Point &A,Point & B){
48+
Point GetLineProjection(Point P,Point A,Point B){
4949
//the projection Point Q of P to Line A,B;
5050
Vector v = B-A;
5151
return A+ v*(Dot(v,P-A)/Dot(v,v));
5252
}
53-
bool SegInsertion(Point &A1,Point &A2,Point &B1,Point &B2){
53+
bool SegInsertion(Point A1,Point A2,Point B1,Point B2){
5454
double c1 = Cross(A2-A1,B1-A1),c2 = Cross(A2-A1,B2-A1);
5555
double c3 = Cross(B2-B1,A1-B1),c4 = Cross(B2-B1,A2-B1);
5656
return dcmp(c1)*dcmp(c2) <0 && dcmp(c3)*dcmp(c4) <0;
5757
}
58-
bool onSegment(Point & P,Point &A,Point &B){
58+
bool onSegment(Point P,Point A,Point B){
5959
return dcmp(Cross(A-P,B-P))==0 && dcmp(Dot(A-P,B-P)) <0;
6060
}
6161
```

0 commit comments

Comments
 (0)