1 vector to raster conversion (the rasterization process includes the following operations):
1) Converts Cartesian coordinates of corners of points and line entities into predetermined points.
In the matrix of resolution and known position values;
2) For polygons, after testing corner points, the remaining line segments are processed.
At this time, we can know when to reach the multilateral level by using the second scan.
The boundary of a shape records its position and attribute values.
2 Polygon transformation (rasterization process includes the following operations):
1) interior point diffusion algorithm;
2) ray algorithm:
3) scanning filling method:
4) Boundary Algebra Algorithm:
5) Complex integral algorithm
1) interior point diffusion algorithm
The algorithm starts from an inner point (seed point) of each polygon and then moves to its eight edges.
Diffuse to adjacent points, and judge whether each new point is on the polygon boundary, if so.
Located on the boundary, the newly added point will not be used as the seed point, otherwise, the neighbor of the non-boundary point is
As a new seed point, this point performs a new diffusion operation together with the original seed point, and
The seed point is given the number of the polygon. Repeat the above process until all seed points are reached.
Fill the polygon until it meets the boundary stop point. The programming of diffusion algorithm is complicated.
Miscellaneous, and in a certain grid accuracy, if the same polygon complex graphics.
Two boundaries fall in the same or two adjacent grids, which will cause polygons to break.
Pass, such a seed point cannot fill the whole polygon.
2) ray algorithm
Ray algorithm can judge whether the data grid points are outside or inside the polygon point by point.
Judging that the ray belongs to a polygon from the point to be judged to the point outside the figure.
The total number of times the boundaries intersect. If the number of intersections is even, the judgment point is outside the polygon.
Part, if it is odd, the judgment point is inside the polygon (Figure 7- 12). adopt
In the ray algorithm, we should pay attention to: when the ray intersects with the polygon boundary, there are some special characteristics.
Special circumstances will affect the intersection number and must be excluded (Figure 7- 13).
3) scanning algorithm
The scanning algorithm is an improvement of the ray algorithm, which turns the ray into a column along the grid array.
Or scan the line in the row direction, and the judgment is similar to the ray algorithm. Scanning algorithm omission
In order to calculate the intersection of light and polygon boundary, a large number of operations are carried out, which greatly improves the calculation efficiency.
Efficiency.
4) boundary algebra algorithm (BAF- boundary algebra
Fill)
Boundary algebra polygon filling algorithm is a vector grid with vector format based on integral idea.
Lattice format conversion algorithm is suitable for polygon vector data conversion to record topological relations.
Switch to the grid structure. Figure 7- 15 shows the transformation of a single polygon, and the polygon is compiled.
Simulate the process of calculating polygon area by integral, and initialize the grid array.
The value of each grid is zero, and the rows and columns of the grid are used as reference axes and defined by polygon boundaries.
Start searching the boundary line clockwise. When the boundary rises (Figure 7- 15-a), it is located at.
Subtract a from all grids with the same row coordinates on the left side of the boundary; When the boundary disappears.
When (Figure 7- 15-b) all grids are on the left side of the boundary (right side as viewed in the forward direction)
Add a value a to the point, the boundary search is completed, and the polygon transformation is completed.
5) Complex integral algorithm
For all grid arrays, judge the polygon compilation to which the grid belongs one by one.
Code, the discrimination method is to calculate the complex product of each polygon closed boundary through the points to be judged.
For polygons, if the integer value is 2? R, the waiting point belongs to this multilateral.
Shape, given the number of polygons, otherwise it is outside the polygon and does not belong to the polygon.