910 likes | 1.11k Views
Chapter 2 Theoretical foundations of CAC. Contents :. 2.1 Primary geometry and algorithm 2.2 graph theory 2.3 computational geometry 2.4 basic approaches of image processing 2.5 digital earth model. 2.1 primary geometry and algorithm. Relations between CAC geometry elements :. 点. 点.
E N D
Chapter 2 Theoretical foundations of CAC
Contents: 2.1 Primary geometry and algorithm 2.2 graph theory 2.3 computational geometry 2.4 basic approaches of image processing 2.5 digital earth model
2.1 primary geometry and algorithm Relations between CAC geometry elements: 点 点 线 线 面 面
Point on the line Point off the line 1. Relationship of point and line Topology relationship between point and line Research emphasis:relationship between point and line segment, judge approach for the topology relationship between point and line, the calculation of distance between point and line
1.1 The relationship judgment between point and line Given a straight line, Its formula is , Then for Function ,select any point in the space, it has: The importance of judging the relationship between point and line
P2 P4 p1 P3 B P6 P5 A 1.2 The judge approach for point and line relationship One purpose of judging point and line relationship is to decide whether a point is on a line Figure 2-1 judgment of point and line relationship(dot line is projection rectangle)
p1 p1 A p2 A p2 (a) (b) 1.3 The distance between point and line The distance between point and line segment may be the distance between the point and one end of the line. It may be the vertical distance between the point and the line segment. Figure 2-2 Two situations of the minimal distance between point and line segment
D P2 P3 p1 最近距离 最远距离 A P5 P4 Figure 2-3 The maximum and minimal distance between point and line segment
相离 共位 相交 2. line-line relationship The foundation of line-line relationship judgment:intersection
l6 k1 l4 l3 k2 l2 L K l5 l1 k3 The judgment of intersection of two 折线 The first step:generate monotonic links The second step:calculate minimal projection rectangle for every monotonic link The third step:comparison figure2-4 monotonic links segmentation and its projection rectangle
3.Point and plane relationship 3.Relationship between triangle and point AB BC CA If satisfy: Figure 2-5: point and triangle position relationship The point P locates inside the triangle, or the point P locates outside the triangle.
void CTView::OnLButtonUp(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default //CView::OnLButtonUp(nFlags, point); if(m_DrawCurrent==2) { float F1=f1(PointXyz[2].x,PointXyz[2].y); float F2=f2(PointXyz[0].x,PointXyz[0].y); float F3=f3(PointXyz[1].x,PointXyz[1].y); float F4=f1(float(mPointOrign.x),float(mPointOrign.y)); float F5=f2(float(mPointOrign.x),float(mPointOrign.y)); float F6=f3(float(mPointOrign.x),float(mPointOrign.y)); if(F1*F4>0 && F2*F5>0 && F3*F6>0) MessageBox(" 点在三角形内!"); else MessageBox(" 点在三角形外!"); ReleaseCapture(); } }
3.2 position relationship between line and polygon • summation algorithm of judging point and polygon position relationship Given a simple n polygon, its vertices can be represented as Pi(xi,yi),i=1,2…,n.In addition, there are independent point A. Link point A to every vertices of the polygon and calculate the summation of 夹角. Given that clockwise angle is positive and counter-clockwise angle is negative ,then
P4 P4 P3 P3 P5 P5 P2 P2 P6 P6 P1 P1 P P Figure 2-8 Figu 2-9
Basic idea: Draw vertical line from judge point. Judge whether the point is in the polygon according to the number of the intersection points between the vertical line and the polyon. If the number is odd, then the point is in the polyon. If the number is even, then the point is out of the polygon • judging position relationship between point and polygon
A1 P2 P1 A2 P5 P4 P3 Figure 2-11 judge the containing relationship between point and polygon according to the number of the intersection points. Is there any special case?
P2 A P2 P1 P1 A P3 P3 P4 P4 (b) (a) Figure 2-12: the intersection between the vertical line and polyon is vertex
P2 P1 P2 P3 A P1 A P3 P6 P4 P4 P5 P5 (b) (a) Figure 2-13 The vertical line overlaps one side of the polygon
部分源代码: void CDraw1View::judge2(float x, float y) { float xmax=PointXyz[0].x; float xmin=PointXyz[0].x; float ymin=PointXyz[0].y; float fy; //fy为待判断点与直线方程的交点的纵坐标 int num=0; //记录待判断点与直线方程的交点的数目 PointXyz[a].x=PointXyz[0].x; PointXyz[a].y=PointXyz[0].y; PointXyz[a+1].x=PointXyz[1].x;PointXyz[a+1].y=PointXyz[1].y; PointXyz[a+2].x=PointXyz[2].x; PointXyz[a+2].y=PointXyz[2].y; PointXyz[a+3].x=PointXyz[3].x; PointXyz[a+3].y=PointXyz[3].y;
for(int j=0;j<a;j++) { fy=(((x-PointXyz[j].x)*(PointXyz[j+1].y-PointXyz[j].y))/(PointXyz[j+1].x-PointXyz[j].x))+PointXyz[j].y; if(fy>=y&&((PointXyz[j].x<x&&x<PointXyz[j+1].x)||(PointXyz[j+1].x<x&&x<PointXyz[j].x))) // 纵坐标越往下,值越大 {num=num+1; continue;} else if(x==PointXyz[j+1].x&&fy==PointXyz[j+1].y) // 交于多边形顶点时 { if(((PointXyz[j].x<x&&x<PointXyz[j+2].x)||(PointXyz[j+2].x<x&&x<PointXyz[j].x))&&PointXyz[j+2].y>y) //若前后相邻的两顶点在该顶点所做铅垂线分得异侧,则num++ num=num+1; else if(x==PointXyz[j+1].x&&x==PointXyz[j+2].x&&PointXyz[j+2].y>y) //若铅垂线与边部分重合 { if((PointXyz[j+3].x<x&&x<PointXyz[j].x)||(PointXyz[j].x<x&&x<PointXyz[j+3].x)) num=num+1; } } } if(num%2==1) { MessageBox("点在多边形内!");} else if(num%2==0) { MessageBox("点在多边形外!");} }
4. Line and plane relationship The key problem of line and plane relationship is to find the intersection of line and plane. The algorithm of the intersection of line segment and polygon : Step 1,calculate the minimal projection rectangle of the polygon. Step 2,judge whether any end of the line segment is in the minimal projection rectangle. If no end is in the minimal projection rectangle, the conclusion is that “line is outside the polygon”, algorithm terminates. Otherwise, go to step 3.
Step 3, judge whether there is intersection point between the line segment and each side of the polygon. If there exist intersect point, calculate and save the coordinate of the intersection point. Step 4, sort the intersection points. Calculate the distance between each intersection point and one end of the line segment. Then sort the intersection points ordered from the small distances to large distances. Step 5, link each intersection points and obtain the intersection line inside the polygon
p8 p6 p2 p11 p4 p1 q10 q8 q2 q6 H Q q1 q3 q7 q5 q9 q4 p3 p7 p5 k1 k3 k2 p14 K M p10 p13 p12 p9 Figure 2-14: the rules of the intersection between line and polygon
5. plane-plane relationship The foundation of the calculation of the intersection between any two polygons is the algorithm that calculate intersection, differ and union of two simple polygon.
p2 p1 q3 k1 q2 k2 k3 q1 k8 p3 q7 k7 k4 q6 p5 p4 k6 q4 k5 p6 q5 Figure 2-15 The intersection of simple polygons
Q0 P0 P Q1 Q P1 P2 Figure 2-17 The intersection of two complex polygons
A B C D Figure 2-18 The seven bridges problem 1、图论的起源与发展 The foundation of graph theory:The Seven Bridges of Konigsberg question:“can you pass each bridge one and only one time and return to the start point?”
2.图的概念 v1 directed edge extreme point Start point End point e1 e3 v2 e2 v3 Figure 2-19 Directed Graph v1 e1 e3 Graph v2 e2 v3 Association Adjacent
e2 e4 v3 v2 v4 e3 e5 e1 v5 e7 e6 v6 v1 e8 Figure 2-20 non-simple directed graph Circle Parallel Edge Symmetric Edge Isolated Vertex Graph containing no circle is calle forest;connected graph not containing circle is called tree
3. Matrix representation of graph The matrix representation of graph bridges the matrix theory and graph theory Adjacent matrix is a effective representation approach for graph. Graph is often stored as adjacent matrix in the computer. The so-called adjacent matrix is referred to as vv order matrix. The so called incidence matrix refers to ve order matrix
e7 v3 v2 e6 e1 e5 e4 e3 e2 v4 v1 Undirected graph matrix
e7 v3 v2 e6 e1 e5 e4 e3 e2 v4 v1 Directed graph matrix
7 5 4 4 3 2 9 3 2 (a) -7 5 4 4 -3 -2 9 3 2 (b) Figure 2-23 weighted graph. (a)undirected weighted graph; (b)directed weighted graph
Computational Geometry is a interdisciplinary that is composed of function approximation theory, algebra geometry and computational mathematics. It study computational representation of geometry information, analysis and synthesis. Computational geometry has significant applications in many fields such as CAD, CAM,CAC,graphics,robert technique,VLSI design.
1. Curve fitting definition Finding a curve that strictly go through a set of given points is a interpolation problem. Finding a curve that approximately go through a set of given points is approximation problem.
Spatial interpolation can be classified into continuous spatial interpolation and discrete spatial interpolation. Spatial interpolation techniques can be classified into global fitting (trend-surface analysis) and local fitting (spline function). Interpolation methods include linear interpolation, bilinear polynomial interpolation, double cubic polynomial (spline function) interpolation, least square trend surface, Fourier series, Kriging moving average method.
2. Convex Hull Definition: Convex Hull of Plane point set S refers to minimal convex set that contains S. Normally it is represented as CH(S). Judging from geometry intuition, Convex Hull of S shows that the line segment linking any point in the S is completely in the convex hull. Boundary convex hull of Plane point set S BCH(S) is a convex polygon, whose vertices are in S. Convex Hull is the most common and fundamental structure in computational geometry.
Diameter of Convex Polygon is also called diameter of plane point set or diameter of plane point set convex hull. It is the distance of furthest vertex pair of convex polygon.
x 2.1 Algorithm that finds convex hull of plane point set Figure 2-26 Gramham Algorithm
2.2 Algorithm that calculate diameter of convex polygon. Figure 2-27 Angle sequence algorithm
Given two points P1,P2 on the plane, L is perpendicular bisector of P1P2,L divides the plane into two parts Lr and Ll。points in Ll has property: d(Pi,P1)<d(Pi,P2),where d(Pi,Pl) is Euclidean distance between Pi,Pl。 Points in Ll is closer to Pl than any other points in the plane. In the other word,points in Ll is the trajectory of points that are closer to Pl than any other points in the plane and is indicated as V(P1)。Similarly,points in Lr is the trajectory of points that are closer to P2 than any other points and is indicated as V(P2)。 3.Voronoi图 3.1 Voronoi diagram definition Figure 2-28 Voronoi diagram of two points on the plane
Nature of Voronoi Diagram Voronoi Diagram can be understood as a space partition method(distance from any point A in a Voronoi polygon to the center of the polygon is less than the distances from the point A to the centers of other Voronoi polygon). It also can be understood as a spatial interpolation method ( the value of any unknown point in the space can be substituted by the value of the closest point i.e. sample point)
4. Delaunay三角网 4.1 Definition of Delaunay triangular mesh Voronoi polygons with common border are called adjacent Voronoi polygons. Triangular mesh that are generated by connecting the center of all adjacent Voronoi polygons is called Delaunay triangular mesh
4.2 Properties of Delaunay Triangular Mesh (1)It is unqiue; (2)The outside boundary of triangular form the convex hull of point group (3)The circumcircle of triangular contains no other points-circumcircle rule (4)triangular keeps balance as much as possible to avoid long-narrow triangular mesh – maximum minimal angular rule. (5)Delaunay triangular mesh is planar graph. It follows euler theorem of plane graphic. (6)Delaunay triangular mesh mostly has 3n-6 edges and 2n-5 triangular. Here n is the number of points; (7)Delaunay triangular mesh and Voronoi diagram is a dual. Getting one can easily lead to getting the other.
2.4 basic image processing approaches. partition New grey value 255 Non-linear inverse 200 linear 45º piecewise 100 Threshold operation Original grey value 100 200 255 Figure 2-32 different transform function curves of grey value tranformation 1. Grey value transformation