Aliquot of isometric line - an important algorithm for an application

zhaozj2021-02-16  46

Isometric line painting

Xu Qingrong, this article (Wuhan University)

Aliquots can be divided into two types and vector modes of the raster (grating). The raster method generally uses an operator such as "distance transformation", and the algorithm is concise, but the equidistant in different directions may not be strict. Vector way is to obtain an equidist line position by coordinate calculation according to the geometric relationship, and the algorithm is complex, but the precision is high. This article describes the vector mode of a vector method.

1 Overview

Briefly, the isometric line refers to a line with a known line (fold line or curve) isometric. The application of the equidistant is widely used, for example: various linear symbols (such as roads, pipelines, etc.) composed of parallel lines (such as roads, pipelines, etc.) on a map; in the polygonal shape, a series of closed isometric lines Or in the coordinate line, such as the graphic generated by the Effects-> Contour option in CorelDRAW) to represent a regional feature; when the GIS "Buffer Belt" analysis, the contour of the "Buffer Belt" is central axis with a certain linear element. Constructs the equidist line on both sides and closes both ends. Another example, coastal countries can calculate the boundaries of the exquisite economic zone at the same distance. In addition, the equidistor is also used in CNC machine tools calculation and robot walking path planning.

It is known from the distance from the equidistant line deviation (normal direction). If there is a known curve C, each point in the normal direction (on the same side) is attached to the point phase D, the trajectory C0 of these points is referred to as the equidistant of the curve C.

Here, we are called the known lines (lines or curves) based on the constructed equidistylline as the original line. When the original line is a line, the equidistor can be generated by the "push line" method. If the original line is any parameter curve C (T), the math expression of its equidistant is theoretically

C0 (t) = c (t) ± (d · n (t))

T is the curve parameters, n (t) is the unit main method of the unit of the curve at T, and the direction is directed to the side of the curve. The positive or negative of the formula depends on the deviation direction of the equidistant. When the equidistor deviation direction is in the same direction as the main method, the normal is taken, and the negative is taken. At the curve turning point, the method is uncertain, it is necessary to treat special treatment. If c (t) = {x (t), y (t)}, that is, C (t) is a planar parameter curve, then

N (t) = {- y '(t) / SQRT ((x' (t)) 2 (Y '(t)) 2), x' (t) / sqRT ((x '(t)) 2 (Y '(t)) 2)}

2. Aliquot of the fold line

The original line is the equidistant line of the fold line, its calculation and drawing process ("push line") is as follows.

(1) Calculate the horizontal branch direction B at the folding node (turning point of each line segment) B

The fold line is composed of each line segment, adjacent to the horizontal branch at the same side parallelline equidist from each line segment. Here, it is agreed: the angular flat direction points to the left side of the fold line (the case where the line segment is in the direction of the direction), and is the angle of the reverse clockwise direction from the X-axis. The angular spinning direction B can be calculated from the direction of the adjacent two straight line segments.

(2) Calculate the node coordinates of the equidistant

Here, the equidistor node refers to the junction of the adjacent straight segment on the equidistor, which is located on the angle slot, and the coordinates (X0, Y0) of the equidistant node corresponding to the original line node (x, y). :

X0 = x ± d '× cosby0 = y ± d' × sinb

The intercept of the equidistor in the angular flat branch can be calculated from D and adjacent two straight segments, and D '> D can be generally d. If the left side of the fold line is equidistant, the symbol before D 'should take the normal number, and the negative is taken.

For the non-closed fold, at the head, at the end, in the direction of the straight segment perpendicular to the line segment. The equidistor is in the first, and the end point coordinates at the end are also calculated in the above formula.

(3) Connect the equal distance from the equal line nodes from the alternative line point until the end point (or can also be connected)

3. Aliquot of parameter curve

During the aliquot of the calculation of the parameter curve, the original curve C (T) and the isometric wire C0 (T) must be applied with the polymer (T), ie according to the accuracy requirements of the approximation, Curve C (T) Discrete, calculated equidistant line points on the discrete point, and finally, the fold line formed by each of the equal distance line points is approximately as the equidistant line C0 (t). The specific process is as follows.

(1) Let the curve parameter t = t0 (t0 is the parameter at the start of the curve), calculates N (t) and the equidist line point at the start of the curve;

(2) Determine ΔT according to the accuracy requirements of approximation C (T) and C0 (T), and at the next discrete point (T = T ΔT), the N (t) and the equidistor point of the original curve are calculated;

(3) Repeated (2) process until the end point;

(4) Sequentially connect each equidist line point (or can also be calculated).

The value of ΔT can also be determined according to the curve segment, and the same ΔT is employed on the same stage curve in change.

The parameter curve is often used to fit various irregular curves, which already have a certain error. Therefore, when the orientation of such a curve is actually calculated, the curve can be discretized and approximately according to the fold line.

4. Abnormal handling

When the equidistor is large when the spacing of the original line (the fold or curve) is large (D is larger than the radius of curvature of the original curve), or the original line is twice the own spacing of the original line, the calculated isomeration is calculated. The line may produce self-intersection (form an "self-enhancing"), uncoordinated abnormality. During the calculation process, it can be discriminated and eliminated as follows (as an example of the contour line of the line).

(1) Eliminate "reverse self-circulation"

We call one of the following is a reverse self-enhancing (excluding the first, the end closed isometric coil):

a. When the isometric wire is in the left side of the original line, the equidistant is coming to the alternate line.

b. When the isometric line is on the right side of the original line, the equidistant to the counterclockwise is self-contained.

(2) If the equidistor is included in the self-container, the self-container should be eliminated.

If a straight line segment on the isometric line is opposite to the straight line segment on the corresponding original line, the linear segment on the equidistor is referred to as a reverse line segment. The self-circular circle containing the reverse line segment should be deleted regardless of the direction of the circle.

(3) Eliminate uncoordinated bends containing "reverse line segments"

Although not in the self-circulation, if the equidistor line segment is a reverse line segment, the bending of the original line is not coordinated. At this time, adjust or delete should be adjusted, so that the alternating line does not contain the reverse line segment, thereby eliminating uncoordinated bending.

(4) Eliminating the self-circulation or line segment of the adjacent raw line is less than D. If the distance from the adjacent raw wire is less than D (the distance to the original line when calculating the equidist line), it should be deleted Go to the line segment. If such a line segment is located in the self-circulation, the entire self-circulation should be deleted.

For the equidistant of the curve, if it is discretized during processing, the above principles can also be applied.

Various abnormalities that may occur in the equidistant, are still difficult to completely expect; the calculation error of the machine accuracy may result in discrimination errors. The above elimination of abnormalities is just a preliminary, and there is still a further solution.

5. Application

Algorithm for the above equity line generation and abnormal processing has been used for the graphics software development tool UGS (universal drawing software), UGS uses this method to be generated in the region, the equidistrape texture, the effect is as follows. UGS is posted on 9CBS (graphics processing class), download: http://www.9cbs.net/cnshare/shtm/18.shtm

Author published in 9CBS related articles:

Vector drawing algorithm with "unrelated to graphics structure"

Add a new tool for the development of graphics software

Contact: Short information can be sent to XQR at the 9CBS forum.

转载请注明原文地址:https://www.9cbs.com/read-26356.html

New Post(0)