A method for drawing arcs without distortion for HUD
Through the arc-oriented arc-free distortion drawing method, the multi-sampling algorithm and the rectangular plane coordinate system are used to solve the problem of poor anti-aliasing effect of arc-sections and the extension line not passing through the center, achieving distortion-free drawing and optimized display effects.
Patent Information
- Application Number
- CN202210501103.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-10
- Publication Date
- 2025-04-22
- Estimated Expiration
- 2042-05-10
AI Technical Summary
In the prior art, when drawing arcs, there are problems such as poor anti-aliasing effect on the sections and the extension line does not pass through the center of the circle, making it difficult to achieve distortion-free drawing.
The arc-oriented arc-oriented without distortion is adopted. By constructing a rectangular plane coordinate system, the range of the rectangular scanning box is determined, and all pixel points in the rectangular scanning box are traversed based on the multi-sampling algorithm, the difference between the distance and radius between the sampling point and the center of the arc is calculated, and whether the sampling point is within the arc angle is determined, and the weight value is determined to achieve the anti-aliasing effect.
The arcs with no distortion drawing of any line width, radius, and span are achieved, which solves the problem of poor anti-aliasing effect on the section and the extension line not passing through the center, and optimizes the display effect of the arc to make it more realistic.
Smart Images

Figure CN114913264B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of graphic display technology, and in particular to a method for drawing an arc without distortion for a head-up display. Background Art
[0002] Arcs are one of the most basic elements of computer graphics. In many display systems, arcs of arbitrary line width, radius, and span need to be drawn. Common algorithms for distortion-free multi-line width arcs, such as the Breasenham algorithm and the positive-negative method, do not process arc sections. There are problems such as poor anti-aliasing of arc sections and the extension line of arc sections does not pass through the center of the circle. How to quickly and easily draw distortion-free arcs has become an important research topic. Summary of the invention
[0003] In view of the deficiencies in the prior art, the present invention provides a method for drawing arcs without distortion for a head-up display, which can solve the problems of poor anti-aliasing effect of arc sections and the fact that the extension line of the arc sections does not pass through the center of the circle. The method is applicable to any line width, radius, and span and has low hardware requirements.
[0004] To achieve the above object, the present invention adopts the following technical solutions:
[0005] A method for drawing an arc without distortion for a head-up display, the method comprising the following steps:
[0006] S1, constructing a rectangular plane coordinate system with the center of the arc as the origin, and determining the range of a rectangular scanning frame by the center, radius and line width of the arc, the rectangular scanning frame encompassing the arc and three mirrored arcs with the x-axis, y-axis and center as references respectively;
[0007] S2, based on the multi-sampling algorithm, traverse all the pixels in the rectangular scanning frame, generate n·n sampling points for each pixel, obtain the distance value between the sampling point and the center of the arc, calculate the difference between the distance value and the radius, and judge whether the sampling point is within the arc angle; combine the judgment result and the calculated difference to count the number of sampling points that meet the conditions to determine the weight value of each pixel point, and calculate the RGBA value of the corresponding pixel point in combination with the weight value of each pixel point to complete the drawing of the distortion-free arc.
[0008] To optimize the above technical solutions, the specific measures taken also include:
[0009] Furthermore, in step S1, the process of determining the range of the rectangular scanning frame by the center, radius and line width of the arc includes the following steps:
[0010] S11, the arc is drawn counterclockwise, with the center of the arc at (x c ,y c), the radius is R, the line width is Width, and the arc span is α-θ; the value range of θ is [0°, 360°), the value range of α is (0°, 720°), and the value range of α-θ is (0°, 360°);
[0011] S12, with the arc center (x c ,y c ) is used as the origin to construct a rectangular plane coordinate system;
[0012] S13, according to the arc center (x c ,y c ), the arc radius R and the arc line width Width determine the lower left corner vertex (x min ,y min ) and the upper right vertex (x max ,y max ); where (x min ,y min )=(x c -R-Width,y c -R-Width), (x max ,y max )=(x c +R+Width,y c +R+Width);
[0013] S14, for x min ,y min 、x max ,y max Perform round operation and expand the range of the rectangular scanning frame, and convert (round(x min )-b,round(y min )-b) as the lower left corner vertex of the rectangular scanning box, (round(x max )+b,round(y max )+b) is taken as the upper right corner vertex of the rectangular scanning frame; b is the preset threshold, which is an integer multiple of the pixel size q.
[0014] Further, in step S2, all sampling points in the rectangular scanning frame are traversed based on the multi-sampling algorithm, the distance value between the sampling point and the center of the arc is obtained, the difference between the distance value and the radius is calculated, and it is determined whether the sampling point is within the arc angle; the process of combining the judgment result and the calculated difference to determine the weight value includes the following steps:
[0015] S21, based on the principle of multi-sampling algorithm, for any pixel point (x s ,y s ), split it into n×n sampling points {(x s+iq / (n+1),y s +jq / (n+1))}, i=1,2,…,n, j=1,2,…,n;
[0016] S22, traverse all sampling points in the rectangular scanning frame, and for the sampling point (x s +iq / (n+1),y s +jq / (n+1)), the included angle between the line connecting the sampling point and the center of the arc and the horizontal line passing through the center of the arc is calculated by the inverse tangent function:
[0017]
[0018] Calculate the difference between the horizontal coordinate of the sampling point and the horizontal coordinate of the center of the circle And the difference between the ordinate of the center of the circle and the ordinate of the sampling point By the difference x d and difference y d The positive or negative condition of angle_sample determines the quadrant where the sampling point is located to correct the value of angle_sample.
[0019]
[0020] S23, calculate the difference between the distance and radius of each sampling point and the center of the arc
[0021] S24, judging whether the sampling point is within the range of the drawn arc according to the values of fraction_sample and angle_sample, and indicating it with In, where In=1 indicates that the sampling point is within the range, and In=0 indicates that the sampling point is not within the range:
[0022] When α∈(0°,360°), if angle_sample∈[θ,α] and fraction_sample∈[0,Width], then In=1;
[0023] When α∈(360°,720°), if angle_sample∈[0°,α-360°] and fraction_sample∈[0,Width], then In=1; if angle_sample∈[θ,360°] and fraction_sample∈[0,Width], then In=1;
[0024] S25, let mask be the pixel point (x s ,y s ) is the number of sampling points within the range, and the pixel point (x s ,y s)’s weight value ω s .
[0025] Further, in step S25, the weight value ω is calculated according to the following formula: s :
[0026] ω s =mask / (n×n).
[0027] Furthermore, calculating the RGBA value of the corresponding pixel in combination with the weight value of each pixel means that the RGBA value of the drawn pixel is calculated by multiplying the RGBA of the center of the arc by the weight.
[0028] The beneficial effects of the present invention are:
[0029] First, the method for drawing arcs without distortion for HUD of the present invention can realize the drawing of arcs with arbitrary line width, radius and span without distortion, supports the drawing of arcs with floating point numbers as the center, has good display effect and strong practicality.
[0030] Secondly, the method for drawing arcs without distortion for HUD of the present invention solves the problem of poor anti-aliasing effect of arc sections, optimizes the jagged phenomenon of arc sections, applies better anti-aliasing effect to the entire arc, and optimizes the display effect of the arc.
[0031] Thirdly, the method for drawing an arc without distortion for a head-up display of the present invention solves the problem that the extension line of the arc section does not pass through the center of the circle, optimizes the display effect of the arc, and makes the presentation effect of the arc more realistic. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A schematic diagram of the arc drawing principle of an embodiment of the present invention;
[0033] Figure 2 A schematic diagram for determining the weight value of each pixel;
[0034] Figure 3 a is a simulation display effect diagram of arcs of various spans using a common arc drawing algorithm;
[0035] Figure 3 b is a diagram showing the simulated display effects of arc drawing of various spans according to the arc distortion-free drawing method of an embodiment of the present invention. DETAILED DESCRIPTION
[0036] The present invention will now be described in further detail with reference to the accompanying drawings.
[0037] It should be noted that the terms such as "upper", "lower", "left", "right", "front", "back", etc. cited in the invention are only for the convenience of description and are not used to limit the scope of implementation of the present invention. Changes or adjustments in their relative relationships should be regarded as the scope of implementation of the present invention without substantially changing the technical content.
[0038] The embodiment of the present invention provides a method for drawing an arc without distortion for a head-up display, and the method comprises the following steps:
[0039] S1, construct a rectangular plane coordinate system with the center of the arc as the origin, and determine the range of the rectangular scanning frame by the center, radius and line width of the arc. The rectangular scanning frame includes the arc and three mirrored arcs with the x-axis, y-axis and center as references respectively.
[0040] S2, based on the multi-sampling algorithm, traverses all sampling points in the rectangular scanning frame, obtains the distance value between the sampling point and the center of the arc, calculates the difference between the distance value and the radius, and determines whether the sampling point is within the arc angle; combines the judgment result and the calculated difference to determine the weight value to achieve the anti-aliasing effect and complete the drawing of the distortion-free arc.
[0041] The idea of this embodiment is to determine the range of the rectangular scanning frame by the center, radius and line width of the arc, traverse all sampling points in the rectangular scanning frame based on the multi-sampling algorithm, and determine the weight value according to the difference between the distance and the radius of the sampling point and the center of the arc and whether the sampling point is within the arc angle to achieve anti-aliasing effect and complete the drawing of a distortion-free arc.
[0042] Figure 1 The schematic diagram of the arc drawing principle of this embodiment. The center of the arc is (x c ,y c ), the radius is R, the line width is Width, the arc is drawn in counterclockwise order, the starting angle of the arc is θ∈[0°,360°), the span of the arc is α-θ∈(0°,360°), and the end angle of the arc is α∈(0°,720°). The coordinate axis takes the upper left corner vertex O as the origin, the horizontal right is the positive direction of the X axis, and the vertical downward is the positive direction of the Y axis. Set the center of the arc (x c ,y c ) as the origin O c Establish the second coordinate system and define the upper right corner as the first quadrant, the upper left corner as the second quadrant, the lower left corner as the third quadrant, and the lower right corner as the fourth quadrant. c ,y c ), radius R, line width Width determine the size of the rectangular scanning frame, with (x min ,y min )=(x c -R-Width,y c-R-Width) as the lower left corner vertex of the rectangular scanning box, (x max ,y max )=(x c +R+Width,y c +R+Width) as the top right corner vertex of the rectangular scanning frame. In order to ensure the arc anti-aliasing effect, it is necessary to min ,y min 、x max ,y max Perform rounding operation and appropriately expand the range of the rectangular scanning frame. min )-b,round(y min )-b) as the lower left corner vertex of the rectangular scanning box, (round(x max )+b,round(y max )+b) as the top right corner vertex of the rectangular scanning frame; b is the preset threshold, which is an integer multiple of the pixel size q. For the convenience of calculation, assume that the side length of each pixel is 1, extending from the position of 2 pixels, that is, (round(x min )-2,round(x min )-2) as the lower left corner vertex of the rectangular scanning box, (round(x max )+2,round(y max )+2) as the top right vertex of the rectangular scanning frame. The purpose of setting the preset threshold b is to reserve enough space for anti-aliasing. If b is too large, the traversal of invalid points will increase the efficiency. If b is too small, the anti-aliasing part will be cut by the rectangular scanning frame, making the anti-aliasing insufficient. The value of b is generally 2.
[0043] Figure 2 The following is a schematic diagram of determining the weight value of each pixel. The weight value determination process includes the following steps:
[0044] Step 1: Based on the principle of multi-sampling algorithm, each pixel in the rectangular scanning frame is split into n×n sampling points {(x s +iq / (n+1),y s +jq / (n+1))}, i=1,2,…,n, j=1,2,…,n. The value of n is related to the required anti-aliasing accuracy. If n is too small, the accuracy will be too low. If n is too large, the weight of the change in accuracy is very small, but it will cause the judgment of redundant points and increase the burden on the hardware. In this embodiment, n is selected to be 3.
[0045] When n is 3, each pixel in the rectangular scan frame is split into 3*3 sampling points, with the pixel point (x s ,y s ) as an example, split it into: (xs +0.25,y s +0.25)、(x s +0.5,y s +0.25)、(x s +0.75,y s +0.25),
[0046] (x s +0.25,y s +0.5)、(x s +0.5,y s +0.5)、(x s +0.75,y s +0.5)、(x s +0.25,y s +0.75)、(x s +0.5,y s +0.75)、(x s +0.75,y s +0.75) nine sampling points. All sampling points in the rectangular scanning frame are traversed.
[0047] Step 2: Take the sampling point (x s +0.25,y s +0.25) as an example, the included angle between the line connecting the sampling point and the center of the arc and the horizontal line passing through the center of the arc is calculated by the inverse tangent function:
[0048]
[0049] Because the angle range obtained by the inverse tangent is (-90°, 90°), it is necessary to determine the difference x between the horizontal coordinate of the sampling point and the horizontal coordinate of the center of the circle. d =x s +0.25-x c , the difference y between the ordinate of the center of the circle and the ordinate of the sampling point d =y c -(y s +0.25) to determine the quadrant position of the sampling point and obtain the accurate angle_sample.
[0050] If the sampling point is in the first quadrant, then:
[0051] angle_sample=angle_sample;
[0052] If the sampling points are in the second and third quadrants, then:
[0053] angle_sample=angle_sample+180°;
[0054] If the sampling point is in the fourth quadrant, then:
[0055] angle_sample=angle_sample+360°.
[0056] In summary:
[0057]
[0058] Step 3: While calculating the angle angle_sample, calculate the difference between the distance between each sampling point and the center of the arc and the radius
[0059] Step 4: Determine whether the sampling point is within the drawn arc range according to the values of fraction_sample and angle_sample, and indicate it with In. If In=1, it indicates that the sampling point is within the range, and if In=0, it indicates that the sampling point is not within the range.
[0060] When α∈(0°,360°), if angle_sample∈[θ,α] and fraction_sample∈[0,Width], then In=1;
[0061] When α∈(360°,720°), if angle_sample∈[0°,α-360°] and fraction_sample∈[0,Width], then In=1; or if angle_sample∈[θ,360°] and fraction_sample∈,0,Width-, then In=1.
[0062] Use mask to record each pixel (x s ,y s ) is the number of sampling points within the range, and the pixel point (x s ,y s )’s weight value ω s ,ω s =mask / n. Taking n as 3 as an example, the weight value of each pixel can be calculated by mask / 9 to achieve the anti-aliasing effect and complete the drawing of a distortion-free arc.
[0063] This embodiment presets several sets of arc drawing parameters with different spans. Figure 3 a is the simulation display effect diagram of each span arc using the common arc drawing algorithm. Figure 3 b is a simulation display effect diagram of each span arc drawing of the method of the present invention, and the top image is an enlarged image of the local line. Figure 3 a and Figure 3From each image in b, it can be seen that the common arc drawing algorithm determines the weight of transparency by interpolating the distance between the pixel point and the center of the circle and the radius. The anti-aliasing effect applied in this way only exists in the inner and outer circles of the arc and cannot be applied to the section of the arc. At the same time, this anti-aliasing algorithm does not take into account the problem of the starting and ending angles of the arc, so that the extension line of the arc section will not pass through the center of the arc, which is contrary to the actual effect that the arc should have. The method of the present invention uses a multi-sampling algorithm to apply an anti-aliasing effect to the arc, and imposes two restriction conditions on each sampling point that needs to be traversed to determine whether it is within the line width and angle of the arc. In this way, the anti-aliasing effect is applied to the section of the arc and the section of the arc is smoothed to meet the actual display effect of the arc. By comparison, it can be seen that the arc drawn by the method of the present invention solves the problems of poor anti-aliasing effect of the arc section and the problem that the extension line of the arc section does not pass through the center of the arc, optimizes the jagged phenomenon of the arc section, and applies a better anti-aliasing effect to the arc as a whole. It optimizes the display effect of the arc, makes the presentation effect of the arc more realistic, and supports the drawing of arcs with arbitrary line width, radius, and span.
[0064] The above are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should be regarded as the protection scope of the present invention.
Claims
1. A method for drawing an arc without distortion for a head-up display, characterized in that: The drawing method comprises the following steps: S1, constructing a rectangular plane coordinate system with the center of the arc as the origin, and determining the range of a rectangular scanning frame by the center, radius and line width of the arc, the rectangular scanning frame encompassing the arc and three mirrored arcs with the x-axis, y-axis and center as references respectively; S2, based on the multi-sampling algorithm, traverse all the pixels in the rectangular scanning frame, generate n·n sampling points for each pixel, obtain the distance value between the sampling point and the center of the arc, calculate the difference between the distance value and the radius, and judge whether the sampling point is within the arc angle; combine the judgment result and the calculated difference to count the number of sampling points that meet the conditions to determine the weight value of each pixel, and calculate the RGBA value of the corresponding pixel in combination with the weight value of each pixel to complete the drawing of the distortion-free arc; In step S1, the process of determining the range of the rectangular scanning frame by the center, radius and line width of the arc includes the following steps: S11, the arc is drawn counterclockwise, with the center of the arc at (x c ,y c ), the radius is R, the line width is Width, and the arc span is α-θ; the value range of θ is [0°, 360°), the value range of α is (0°, 720°), and the value range of α-θ is (0°, 360°); S12, with the arc center (x c ,y c ) is used as the origin to construct a rectangular plane coordinate system; S13, according to the arc center (x c ,y c ), the arc radius R and the arc line width Width determine the lower left corner vertex (x min ,y min ) and the upper right vertex (x max ,y max ); where (x min ,y min )=(x c -R-Width,y c -R-Width), (x max ,y max )=(x c +R+Width,y c +R+Width); S14, for x min ,y min 、x max ,y max Perform round operation and expand the range of the rectangular scanning frame, and convert (round(x min )-b,round(y min )-b) as the lower left corner vertex of the rectangular scanning box, (round(x max )+b,round(y max )+b) as the upper right corner vertex of the rectangular scanning frame; b is a preset threshold, which is an integer multiple of the pixel size q; In step S2, all sampling points in the rectangular scanning frame are traversed based on the multi-sampling algorithm, the distance value between the sampling point and the center of the arc is obtained, the difference between the distance value and the radius is calculated, and it is determined whether the sampling point is within the arc angle; the process of combining the judgment result and the calculated difference to determine the weight value includes the following steps: S21, based on the principle of multi-sampling algorithm, for any pixel point (x s ,y s ), split it into n×n sampling points {(x s +iq / (n+1),y s +jq / (n+1))}, i=1,2,…,n, j=1,2,…,n; S22, traverse all sampling points in the rectangular scanning frame, and for the sampling point (x s +iq / (n+1),y s +jq / (n+1)), the included angle between the line connecting the sampling point and the center of the arc and the horizontal line passing through the center of the arc is calculated by the inverse tangent function: Calculate the difference between the horizontal coordinate of the sampling point and the horizontal coordinate of the center of the circle And the difference between the ordinate of the center of the circle and the ordinate of the sampling point By the difference x d and difference y d The positive or negative condition of angle_sample determines the quadrant where the sampling point is located to correct the value of angle_sample. S23, calculate the difference between the distance and radius of each sampling point and the center of the arc S24, judging whether the sampling point is within the range of the drawn arc according to the values of fraction_sample and angle_sample, and indicating it with In, where In=1 indicates that the sampling point is within the range, and In=0 indicates that the sampling point is not within the range: When α∈(0°,360°), if angle_sample∈[θ,α] and fraction_sample∈[0,Width], then In=1; When α∈(360°,720°), if angle_sample∈[0°,α-360°] and fraction_sample∈[0,Width], then In=1; if angle_sample∈[θ,360°] and fraction_sample∈[0,Width], then In=1; S25, let mask be the pixel point (x s ,y s ) is the number of sampling points within the range, and the pixel point (x s ,y s )’s weight value ω s ; In step S25, the weight value ω is calculated according to the following formula: s : oh s = mask / (n×n).
2. The method for drawing an arc without distortion for a head-up display according to claim 1, characterized in that: Calculating the RGBA value of the corresponding pixel point in combination with the weight value of each pixel point means that the RGBA value of the drawn pixel point is calculated by multiplying the RGBA of the center of the arc by the weight.
Citation Information
Patent Citations
Line pattern anti-aliasing display method
CN103617640A
Quick drawing method of any-angle circular arc
CN104217450A