Curve drawing method, device, equipment and readable storage medium
By filtering and connecting initial coordinate points, the target curve is formed, and the problem of time-consuming and low efficiency of curve drawing in the prior art is solved, and faster and more efficient curve drawing is achieved.
Patent Information
- Application Number
- CN202311068685.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-23
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2043-08-23
AI Technical Summary
The existing curve drawing methods are large in number of coordinate points and long time to connect coordinate points, which makes drawing curves take a long time, inefficient, and may cause lag.
By determining the initial coordinate points to be connected in order, filtering the initial coordinate points according to the set filtering rules, obtaining the target coordinate points, and connecting them in the order of the target coordinate points to obtain the target curve. The target curve consists of several line segments, and the line segments between two adjacent target coordinate points pass through the initial coordinate point between two adjacent target coordinate points.
While ensuring the correctness of the curve, the number of initial coordinate points for the required connection is reduced, the connection time is saved, the lag is avoided, and the efficiency of drawing the curve is improved.
Smart Images

Figure CN116863030B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and more specifically, to a curve drawing method, device, equipment and readable storage medium. Background Art
[0002] In recent years, with the development and popularization of Internet information technology, more and more methods for automatically drawing curves based on coordinate points have emerged and applied in various scenarios. For example, in simulation scenarios, simulation software is usually used to automatically draw simulation curves based on the coordinate points obtained by simulation calculations. The existing method of drawing curves is usually to obtain the coordinate points to be connected and connect the coordinate points to obtain the curve. However, the number of coordinate points is usually very large, the time consumed to connect the coordinate points will be very long, and there will be jamming, which will result in a long time and low efficiency in drawing curves. Summary of the invention
[0003] In view of this, the present application provides a curve drawing method, device, equipment and readable storage medium to solve the problem of existing curve drawing methods. Since the number of coordinate points is very large, the time consumed to connect the coordinate points will be very long, and there will be jamming, resulting in a long time and low efficiency in drawing curves.
[0004] In order to achieve the above objectives, the proposed solution is as follows:
[0005] A curve drawing method, comprising:
[0006] Determine the initial coordinate points to be connected in order;
[0007] The initial coordinate points are screened according to the set screening rules to obtain the target coordinate points;
[0008] According to the arrangement order of the target coordinate points, the target coordinate points are connected to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or the two adjacent target coordinate points on it are not in the same pixel.
[0009] Preferably, the screening of the initial coordinate points according to the set screening rules to obtain the target coordinate points includes:
[0010] Combining the initial coordinate points into an ordered sequence in sequence according to the arrangement order of the initial coordinate points;
[0011] In the ordered sequence, the first initial coordinate point is taken as the starting point, and the nearest initial coordinate point that is not in the same pixel as the starting point is determined as the end point, and the initial coordinate points between the starting point and the end point in the ordered sequence are deleted;
[0012] Determine whether the end point is the last initial coordinate point in the ordered sequence;
[0013] If so, taking each initial coordinate point in the ordered sequence as each target coordinate point;
[0014] If not, in the ordered sequence, determine the nearest initial coordinate point after the end point that is not in the same pixel as the end point as the first initial coordinate point, and delete the initial coordinate points in the ordered sequence between the end point and the first initial coordinate point;
[0015] Determine whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0016] If not, taking the end point as a new starting point, taking the first initial coordinate point as a new end point, and returning to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0017] If so, determine whether the first initial coordinate point is on the extension line of the line segment from the starting point to the end point. If so, delete the end point in the ordered sequence, use the first initial coordinate point as the new end point, and return to execute the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
[0018] Preferably, it also includes:
[0019] If the first initial coordinate point is not on the extension line of the line segment from the starting point to the end point, then in the ordered sequence, determine the nearest initial coordinate point after the first initial coordinate point that is not in the same pixel as the first initial coordinate point as the second initial coordinate point, and delete the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence;
[0020] Determine whether the first initial coordinate point is on the extension line of the line segment from the end point to the starting point;
[0021] If yes, determine whether the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point;
[0022] If the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point, then delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0023] If the second initial coordinate point is not on the extension line of the line segment from the end point to the first initial coordinate point, determining whether the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point;
[0024] If the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point, then delete the end point in the ordered sequence, take the first initial coordinate point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0025] If the second initial coordinate point is not on the extension line of the line segment from the first initial coordinate point to the end point, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
[0026] Preferably, it also includes:
[0027] If the first initial coordinate point is not on the extension line of the line segment from the end point to the starting point, determining whether the second initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0028] If yes, delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0029] If not, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
[0030] Preferably, the process of determining the nearest initial coordinate point that is not within the same pixel as the starting point includes:
[0031] In the ordered sequence, for each initial coordinate point except the starting point, the square of the pixel distance between the initial coordinate point and the starting point is calculated in turn according to the following formula: Until the calculated square When it is less than 1, the square of the calculated value When it is less than 1, the initial coordinate point corresponding to it is determined as the nearest initial coordinate point that is not in the same pixel as the starting point:
[0032]
[0033] Among them, (x1, y1) is the initial coordinate point other than the starting point, (x2, y2) is the starting point, (p x ,p y ) is the pixel size within the drawing window.
[0034] Preferably, determining whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point includes:
[0035] Determine whether a line segment between the first initial coordinate point and the starting point or a line segment between the first initial coordinate point and the end point is parallel to a line segment between the starting point and the end point;
[0036] If yes, then determining that the first initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0037] If not, it is determined that the first initial coordinate point is not on the extension line of the line segment between the starting point and the end point.
[0038] Preferably, determining whether a line segment between the first initial coordinate point and the starting point or a line segment between the first initial coordinate point and the end point is parallel to a line segment between the starting point and the end point includes:
[0039] The direction of the line segment from the starting point to the first initial coordinate point is calculated according to the following formula Or, the direction of the line segment from the end point to the first initial coordinate point is calculated according to the following formula:
[0040]
[0041]
[0042] Wherein, (x2, y2) is the starting point, (x3, y3) is the first initial coordinate point, (x4, y4) is the end point, (p x ,p y ) is the pixel size of the drawing window;
[0043] The direction of the line segment from the starting point to the end point is calculated according to the following formula:
[0044] If the direction With the direction satisfy Then determine that the line segment between the first initial coordinate point and the starting point is parallel to the line segment between the starting point and the end point;
[0045] If the direction With the direction satisfy Then, it is determined that the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point.
[0046] A curve drawing device, comprising:
[0047] Each initial coordinate point determination unit is used to determine each initial coordinate point to be connected that is arranged in sequence;
[0048] Each target coordinate point acquisition unit is used to filter the initial coordinate points according to the set filtering rules to obtain each target coordinate point;
[0049] A target curve acquisition unit is used to connect the target coordinate points according to the arrangement order of the target coordinate points to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or the two adjacent target coordinate points on it are not in the same pixel.
[0050] A curve drawing device, comprising a memory and a processor;
[0051] The memory is used to store programs;
[0052] The processor is used to execute the program to implement each step of the aforementioned curve drawing method.
[0053] A readable storage medium stores a computer program, and when the computer program is executed by a processor, each step of the above-mentioned curve drawing method is implemented.
[0054] It can be seen from the above technical solution that the curve drawing method provided in the embodiment of the present application determines the initial coordinate points to be connected arranged in order, filters the initial coordinate points according to the set filtering rules to obtain the target coordinate points, and connects the target coordinate points according to the arrangement order of the target coordinate points to obtain the target curve. Since the target curve is composed of several line segments, at the pixel level, the line segment between two adjacent target coordinate points passes through each initial coordinate point between the two adjacent target coordinate points, so that the curve obtained by connecting each initial coordinate point is consistent with the shape effect presented by the target curve, thereby ensuring the correctness of the target curve. In addition, while ensuring the correctness of the target curve, since the number of target coordinate points on each line segment on the target curve is less than or equal to the number of initial coordinate points on it, the number of initial coordinate points required to be connected is reduced. Since the two adjacent target coordinate points on each line segment on the target curve are not in the same pixel, and the two initial coordinate points in the same pixel present the same effect, the two initial coordinate points with the same presentation effect are avoided from being connected, the number of initial coordinate points required to be connected is reduced, the connection time is saved, the occurrence of jams is avoided, the time for drawing the target curve is saved, and the efficiency of drawing the target curve is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0056] Figure 1 A flow chart of a curve drawing method disclosed in an embodiment of the present application;
[0057] Figure 2 A flowchart of a method for filtering each initial coordinate point according to a set filtering rule to obtain each target coordinate point disclosed in an embodiment of the present application;
[0058] Figure 3a-3f A schematic diagram of a process of screening each initial coordinate point according to a set screening rule to obtain each target coordinate point disclosed in an embodiment of the present application;
[0059] Figure 4 A schematic diagram of the structure of a curve drawing device disclosed in an embodiment of the present application;
[0060] Figure 5 This is a hardware structure block diagram of a curve drawing device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0061] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0062] The present application solution can be implemented based on a terminal with data processing capabilities, which can be a computer, server, cloud, etc.
[0063] The present application embodiment provides a curve drawing method. Figure 1 The curve drawing method of this application is described as follows: Figure 1 As shown, the method may include:
[0064] Step S100: determine the initial coordinate points to be connected that are arranged in sequence.
[0065] Specifically, drawing a curve is usually done by connecting sequentially arranged coordinate points in the order of arrangement to obtain the curve. In order to draw the curve, the sequentially arranged initial coordinate points to be connected should first be determined. The initial coordinate points can be the original coordinate points obtained, or the coordinate points obtained after the original coordinate points are obtained and then the abnormal coordinate points are removed.
[0066] Step S110: Screen the initial coordinate points according to the set screening rules to obtain the target coordinate points.
[0067] Specifically, when the number of coordinate points is very large, the time consumed to connect the coordinate points will be very long, and there will be freezes, which will result in a long time and low efficiency in drawing the curve. Therefore, in order to reduce the number of initial coordinate points that need to be connected while ensuring the correctness of the drawn curve, the embodiment of the present application sets corresponding filtering rules, and filters each initial coordinate point according to the set filtering rules to obtain each target coordinate point, so as to connect each target coordinate point in the arrangement order of each target coordinate point.
[0068] Step S120: Connect each target coordinate point in the order of arrangement of each target coordinate point to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through each initial coordinate point between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or, the two adjacent target coordinate points on it are not in the same pixel.
[0069] Specifically, the target curve can be obtained by connecting the target coordinate points according to the arrangement order of the target coordinate points. Since the target curve is obtained by connecting the target coordinate points, the target curve is composed of a plurality of line segments. Since the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points, and when displaying the curve, the pixel is used as the smallest display unit for display, so the target curve is completely consistent with the effect presented by the curve obtained by connecting the initial coordinate points according to the arrangement order of the initial coordinate points, thereby ensuring the correctness of the target curve. Since the number of target coordinate points on each line segment on the target curve is less than or equal to the number of initial coordinate points on it, the number of initial coordinate points required to be connected is reduced. Since the two adjacent target coordinate points on each line segment on the target curve are not in the same pixel, and the two initial coordinate points in the same pixel present the same effect, it is avoided that the two initial coordinate points with the same presentation effect are connected, thereby reducing the number of initial coordinate points required to be connected.
[0070] The curve drawing method provided by the embodiment of the present application determines each initial coordinate point to be connected arranged in order, screens each initial coordinate point according to the set screening rule, obtains each target coordinate point, and connects each target coordinate point according to the arrangement order of each target coordinate point to obtain a target curve. Since the target curve is composed of a plurality of line segments, at the pixel level, the line segment between two adjacent target coordinate points passes through each initial coordinate point between the two adjacent target coordinate points, so that the curve obtained by connecting each initial coordinate point is consistent with the shape effect presented by the target curve, so the correctness of the target curve is guaranteed, and, while ensuring the correctness of the target curve, since the number of target coordinate points on each line segment on the target curve is less than or equal to the number of initial coordinate points on it, the number of initial coordinate points required to be connected is reduced, and since the two adjacent target coordinate points on each line segment on the target curve are not in the same pixel, and the two initial coordinate points in the same pixel present the same effect, it is avoided that two initial coordinate points with the same presentation effect are connected, the number of initial coordinate points required to be connected is reduced, the connection time is saved, the jamming is avoided, the time of drawing the target curve is saved, and the efficiency of drawing the target curve is improved.
[0071] See also Figure 2 In the embodiment of the present application, the process of filtering each initial coordinate point according to the set filtering rule in the above step S110 to obtain each target coordinate point is introduced, and the process may include:
[0072] Step S01, combining the initial coordinate points into an ordered sequence in sequence according to the arrangement order of the initial coordinate points.
[0073] Specifically, the initial coordinate points are sequentially combined into an ordered sequence according to the arrangement order of the initial coordinate points, so as to screen the initial coordinate points in the ordered sequence and only retain the initial coordinate points that must be connected as the target coordinate points.
[0074] Step S02: In the ordered sequence, the first initial coordinate point is taken as the starting point, and the nearest initial coordinate point that is not in the same pixel as the starting point is determined as the end point, and the initial coordinate points between the starting point and the end point in the ordered sequence are deleted.
[0075] Specifically, in an ordered sequence, the first initial coordinate point is the initial coordinate point that must be connected, so the first initial coordinate point is first used as the starting point. Since the two initial coordinate points in the same pixel present the same effect, the most recent initial coordinate point that is not in the same pixel as the starting point is determined as the end point. Since the initial coordinate points between the starting point and the end point in the ordered sequence are all in the same pixel as the starting point, the display effect is consistent with the first initial coordinate point. In order to reduce the initial coordinate points that need to be connected and save connection time, the initial coordinate points between the starting point and the end point in the ordered sequence are deleted.
[0076] Step S03: determine whether the end point is the last initial coordinate point in the ordered sequence.
[0077] If yes, execute the following step S04, if no, execute the following step S05.
[0078] Step S04: taking each initial coordinate point in the ordered sequence as each target coordinate point.
[0079] Specifically, when the end point is the last initial coordinate point in the ordered sequence, it means that the initial coordinate points in the ordered sequence have been screened, so the initial coordinate points in the ordered sequence are used as target coordinate points.
[0080] Step S05: in the ordered sequence, determine the nearest initial coordinate point after the end point that is not in the same pixel as the end point as the first initial coordinate point, and delete the initial coordinate points between the end point and the first initial coordinate point in the ordered sequence.
[0081] Specifically, when the end point is not the last initial coordinate point in the ordered sequence, it means that the screening of the initial coordinate points in the initial sequence has not been completed. Since the starting point and the end point have been determined, and the two initial coordinate points in the same pixel present the same effect, in the ordered sequence, the nearest initial coordinate point after the end point that is not in the same pixel as the end point is determined as the first initial coordinate point, so as to determine whether the end point is an initial coordinate point that must be connected based on the position of the first initial coordinate point. The initial coordinate points between the end point and the first initial coordinate point are all in the same pixel as the end point, and the display effect is consistent with the end point. In order to reduce the initial coordinate points that need to be connected and save connection time, the initial coordinate points between the end point and the first initial coordinate point in the ordered sequence are deleted.
[0082] Step S06: Determine whether the first initial coordinate point is on a first extension line, wherein the first extension line is an extension line of the line segment between the starting point and the end point.
[0083] If not, execute the following step S07, and if so, execute the following step S08.
[0084] Optionally, it can be determined whether the line segment between the first initial coordinate point and the starting point or the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point. If so, it is determined that the first initial coordinate point is on the extension line of the line segment between the starting point and the end point. If not, it is determined that the first initial coordinate point is not on the extension line of the line segment between the starting point and the end point.
[0085] Step S07: take the end point as the new starting point, take the first initial coordinate point as the new end point, and return to execute the above step S03.
[0086] Specifically, if the first initial coordinate point is not on the extension line of the line segment between the starting point and the end point, in order to ensure the correctness of the target curve, the end point is the initial coordinate point that must be connected, and the end point is used as the new starting point, and the first initial coordinate point is used as the new end point, and the step of determining whether the end point is the last initial coordinate point in the ordered sequence is returned to continue determining whether the first initial coordinate point is the initial coordinate point that must be connected.
[0087] Step S08: Determine whether the first initial coordinate point is on the second extension line, wherein the second extension line is the extension line of the line segment from the starting point to the end point.
[0088] Specifically, when the first initial coordinate point is on the extension line of the line segment between the starting point and the end point, there are three situations for the position of the first initial coordinate point. One situation is that the first initial coordinate point is on the extension line of the line segment pointing from the starting point to the end point.
[0089] If yes, execute the following step S09, if no, execute the following step S10.
[0090] Step S09, delete the end point in the ordered sequence, take the first initial coordinate point as the new end point, and return to execute the above step S03.
[0091] Specifically, when the first initial coordinate point is on the extension line of the line segment pointing from the starting point to the end point, the curve obtained by sequentially connecting the starting point, the end point, and the first initial coordinate point is consistent with the curve obtained by sequentially connecting the starting point and the first initial coordinate point. Therefore, the end point is not an initial coordinate point that must be connected. The end point in the ordered sequence is deleted, and the first initial coordinate point is used as the new end point. Return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence, so as to continue to determine whether the first initial coordinate point is an initial coordinate point that must be connected.
[0092] Step S10: in the ordered sequence, determine the nearest initial coordinate point after the first initial coordinate point that is not in the same pixel as the first initial coordinate point as the second initial coordinate point, and delete the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence.
[0093] Specifically, when the first initial coordinate point is on the extension line of the line segment between the starting point and the end point, the other two situations of the position of the first initial coordinate point are that the first initial coordinate point is on the extension line of the line segment from the end point to the starting point and the first initial coordinate point is on the line segment between the starting point and the end point. When the position of the first initial coordinate point is in these two situations, in the ordered sequence, the nearest initial coordinate point after the first initial coordinate point that is not in the same pixel as the first initial coordinate point is determined as the second initial coordinate point, so as to determine whether the end point and the first initial coordinate point must be connected according to the position of the second initial coordinate point. Since the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence are all in the same pixel as the first initial coordinate point, the display effect is consistent with the first initial coordinate point, so the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence are deleted.
[0094] Step S11, determining whether the first initial coordinate point is on the third extension line, wherein the third extension line is the extension line of the line segment from the end point to the starting point.
[0095] If yes, execute the following step S12, if no, execute the following step S17.
[0096] Step S12: determine whether the second initial coordinate point is on a fourth extension line, wherein the fourth extension line is an extension line of a line segment from the end point to the first initial coordinate point.
[0097] Specifically, when the first initial coordinate point is on the extension line of the line segment from the end point to the starting point, it is also necessary to determine whether the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point, so as to determine the end point and whether the first initial coordinate point is the initial coordinate point that must be connected based on whether the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point.
[0098] If yes, execute the following step S13, if no, execute the following step S14.
[0099] Step S13, delete the first initial coordinate point in the ordered sequence, take the end point as the new starting point, take the second initial coordinate point as the new end point, and return to execute the above step S03.
[0100] Specifically, when the second initial coordinate point is on the extension line of the line segment pointing from the end point to the first initial coordinate point, the curve obtained by sequentially connecting the end point, the first initial coordinate point, and the second initial coordinate point is consistent with the curve obtained by sequentially connecting the end point and the second initial coordinate point. Therefore, the end point is an initial coordinate point that must be connected, and the first initial coordinate point is not an initial coordinate point that must be connected. The first initial coordinate point in the ordered sequence is deleted, the end point is used as the new starting point, and the second initial coordinate point is used as the new end point. Return to execute the above step of determining whether the end point is the last initial coordinate point in the ordered sequence, so as to continue to determine whether the second initial coordinate point is an initial coordinate point that must be connected.
[0101] Step S14: determine whether the second initial coordinate point is on the fifth extension line, wherein the fifth extension line is the extension line of the line segment from the first initial coordinate point to the end point.
[0102] Specifically, when the second initial coordinate point is not on the extension line of the line segment from the end point to the first initial coordinate point, it is also necessary to determine whether the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point, so as to determine whether the end point and the first initial coordinate point are the initial coordinate points that must be connected based on whether the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point.
[0103] If yes, execute the following step S15, if no, execute the following step S16.
[0104] Step S15, delete the end point in the ordered sequence, take the first initial coordinate point as the new starting point, take the second initial coordinate point as the new end point, and return to execute the above step S03.
[0105] Specifically, if the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point, the curve obtained by connecting the end point, the first initial coordinate point, and the second initial coordinate point in sequence is consistent with the curve obtained by connecting the first initial coordinate point and the second initial coordinate point in sequence, so the end point is not an initial coordinate point that must be connected, and the first initial coordinate point is an initial coordinate point that must be connected, so the end point in the ordered sequence is deleted, the first initial coordinate point is used as the new starting point, and the second initial coordinate point is used as the new end point, and the step of determining whether the end point is the last initial coordinate point in the ordered sequence is returned to continue determining whether the second initial coordinate point is an initial coordinate point that must be connected.
[0106] Step S16: Use the first initial coordinate point as a new starting point and the second initial coordinate point as a new end point, and return to execute the above step S03.
[0107] Specifically, if the second initial coordinate point is not on the extension line of the line segment from the first initial coordinate point to the end point, the end point and the first initial coordinate point are both initial coordinate points that must be connected, so the first initial coordinate point is used as the new starting point and the second initial coordinate point is used as the new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence, so as to continue determining whether the second initial coordinate point is the initial coordinate point that must be connected.
[0108] Step S17, determining whether the second initial coordinate point is on the first extension line.
[0109] Specifically, when the first initial coordinate point is not on the extension line of the line segment from the end point to the starting point, it means that the first initial coordinate point is on the line segment between the starting point and the end point. At this time, the end point is the initial coordinate point that must be connected, and it is judged whether the second initial coordinate point is on the extension line of the line segment between the starting point and the end point, so as to determine whether the first initial coordinate point is the initial coordinate point that must be connected based on whether the second initial coordinate point is on the extension line of the line segment between the starting point and the end point.
[0110] If yes, execute the following step S18, if no, execute the following step S19.
[0111] Step S18, delete the first initial coordinate point in the ordered sequence, take the end point as the new starting point, take the second initial coordinate point as the end point, and return to execute the above step 03.
[0112] Specifically, if the second initial coordinate point is on the extension line of the line segment between the starting point and the end point, the curve obtained by sequentially connecting the end point, the first initial coordinate point, and the second initial coordinate point is consistent with the curve obtained by sequentially connecting the end point and the second initial coordinate point. Therefore, the first initial coordinate point is not an initial coordinate point that must be connected. The first initial coordinate point in the ordered sequence is deleted, the end point is used as the new starting point, and the second initial coordinate point is used as the new end point. Return to execute the above step of determining whether the end point is the last initial coordinate point in the ordered sequence, so as to continue to determine whether the second initial coordinate point is an initial coordinate point that must be connected.
[0113] Step S19: take the first initial coordinate point as a new starting point, take the second initial coordinate point as a new end point, and return to execute the above step S03.
[0114] Specifically, if the second initial coordinate point is not on the extension line of the line segment between the starting point and the end point, at this time, the first initial coordinate point is the initial coordinate point that must be connected, so the first initial coordinate point is used as the new starting point, and the second initial coordinate point is used as the new end point, and the step of determining whether the end point is the last initial coordinate point in the ordered sequence is returned to continue determining whether the second initial coordinate point is the initial coordinate point that must be connected.
[0115] Next, the process of filtering the initial coordinate points according to the set filtering rules to obtain the target coordinate points is introduced through a specific example:
[0116] Assume that the initial coordinate points are arranged in order:
[0117] (3,2), (3.5,2), (5,4), (2,1), (4,3), (6,4), (6.5,4), (8,5), (9,4). Among them, (3,2) and (3.5,2) are in the same pixel, and (6,4) and (6.5,4) are in the same pixel.
[0118] Combine (3,2), (3.5,2), (5,4), (2,1), (4,3), (6,4), (6.5,4), (8,5), and (9,4) into an ordered sequence, and set points a, b, c, d, and p.
[0119] The first initial coordinate point in the ordered sequence is (3,2). (3,2) is the initial coordinate point that must be connected. Take (3,2) as the starting point, find the nearest coordinate point (5,4) that is not in the same pixel as the starting point (3,2), take (5,4) as the end point, and delete (3.5,2) in the ordered sequence. Figure 3aAs shown, let a and b be the starting points (3,2), c and d be the end points (5,4), and find the nearest initial coordinate point (2,1) that is not in the same pixel as the end point (5,4) as the first initial coordinate point, and let p be the first initial coordinate point (2,1).
[0120] See also Figure 3a and Figure 3b ,because and In the same direction, p On the extension line, that is, the first initial coordinate point (2,1) is on the extension line of the line segment from the end point (5,4) to the starting point (3,2). At this time, let a remain unchanged, a is still the starting point (3,2), let c and d be the first initial coordinate point (2,1), b is the end point (5,4), find the nearest initial coordinate point (4,3) that is not in the same pixel as the first initial coordinate point (2,1), as the second initial coordinate point, let p be the second initial coordinate point (4,3), because p is on the line segment bc, that is, the second initial coordinate point (4,3) is not on the extension line of the line segment from the end point (5,4) to the first initial coordinate point (2,1), nor on the extension line of the line segment from the first initial coordinate point (2,1) to the end point (5,4), so the end point (5,4) and the first initial coordinate point (2,1) are both initial coordinate points that must be connected. Among them, is the direction of the line segment from b to c, is the direction of the line segment from p to b, is the direction of the line segment from c to b.
[0121] See also Figure 3b and Figure 3c , let the first initial coordinate point (2,1) be the new starting point, let the second initial coordinate point (4,3) be the new end point, and let a, b, and c remain unchanged, a is still (3,2), b is still (5,4), and c is still (2,1). Let d point to (4,3), that is, let d be the new end point (4,3), and find the nearest initial coordinate point (6,4) that is not in the same pixel as (4,3) as the first initial coordinate point, and let p be the first initial coordinate point (6,4).
[0122] See also Figure 3c and Figure 3d ,because and Not parallel, that is, the first initial coordinate point (6,4) is not on the extension line of the line segment between the new starting point (2,1) and the new end point (4,3). At this time, the new end point (4,3) is the initial coordinate point that must be connected, so the new end point (4,3) is used as the new starting point, and the first initial coordinate point (6,4) is used as the new end point. Let a and b point to d, and c and d point to p, that is, let a and b be the new starting point (4,3), let c and d be the new end point (6,4), and find the nearest initial coordinate point (8,5) that is not in the same pixel as (6,4) as the first initial coordinate point, and delete (6.5,4), let p be the first initial coordinate point (8,5). Among them, is the direction of the line segment from a to p.
[0123] See also Figure 3d and Figure 3e ,because and Parallel and and In the same direction, p On the extension line, that is, the first initial coordinate point (8,5) is on the extension line of the line segment from the new starting point (4,3) to the new end point (6,4). At this time, delete the new end point (6,4) in the ordered sequence, let the first initial coordinate point (8,5) be the new end point, let c and d be the new end point (8,5), and find the initial coordinate point (9,4) that is not in the same pixel as the nearest (8,5) as the first initial coordinate point, let p be the first initial coordinate point (9,4). Among them, is the direction of the line segment from c to p.
[0124] See also Figure 3e and Figure 3f ,because and Not parallel, that is, the first initial coordinate point (9,4) is not on the extended line between the new starting point (4,3) and the new end point (8,5). At this time, the new (8,5) is the initial coordinate point that must be connected. Let the first initial coordinate point (9,4) be the new end point, and let c and d be (9,4). Since (9,4) is the last initial coordinate point, the screening is completed. At this time, the remaining initial coordinate points in the ordered sequence are (3,2), (5,4), (2,1), (4,3), (8,5), and (9,4). These initial coordinate points are the target coordinate points that need to be connected.
[0125] In the embodiment of the present application, the process of determining the most recent initial coordinate point that is not in the same pixel as the starting point is introduced. The process may include:
[0126] In the ordered sequence, for each initial coordinate point except the starting point, the square of the pixel distance between the initial coordinate point and the starting point is calculated according to the following formula: Until the calculated square When it is less than 1, the square of the calculated value When it is less than 1, the initial coordinate point corresponding to it is determined as the nearest initial coordinate point that is not in the same pixel as the starting point:
[0127]
[0128] Among them, (x1, y1) is the initial coordinate point other than the starting point, (x2, y2) is the starting point, (p x ,p y ) is the pixel size within the drawing window.
[0129] Specifically, the curve is drawn in the drawing window, and the pixel size refers to the coordinate range occupied by a single pixel in the drawing window. For example, the number of pixels in the drawing window is 400×250 (400 pixels horizontally and 250 pixels vertically), and the coordinate range is 10000×200 (the horizontal coordinate range size is about 10000, and the vertical coordinate size is about 200), then the pixel size is 25×0.8, that is, if the horizontal coordinate difference between two coordinate points is less than 25, then the two coordinate points are on the same column of pixels, if the vertical coordinate difference between two coordinate points is less than 0.8, then the two coordinate points are on the same row of pixels, when the square of the pixel distance between two coordinate points is less than 1, the two coordinate points are in the same pixel, so in the ordered sequence, for each initial coordinate point except the starting point, the square of the pixel distance between the initial coordinate point and the starting point is calculated in turn according to the above formula. Until the calculated square When it is less than 1, the square of the calculated value When the initial coordinate point is less than 1, it is determined to be the nearest initial coordinate point that is not in the same pixel as the starting point.
[0130] In the embodiment of the present application, the process of determining whether the line segment between the first initial coordinate point and the starting point or the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point, the process of determining whether the first initial coordinate point is on the extension line of the line segment from the starting point to the end point, and the process of determining whether the first initial coordinate point is on the extension line of the line segment from the end point to the starting point are introduced, respectively:
[0131] The direction of the line segment from the starting point to the first initial coordinate point is calculated according to the following formula Or, calculate the direction of the line segment from the end point to the first initial coordinate point according to the following formula:
[0132]
[0133]
[0134] Among them, (x3, y3) is the first initial coordinate point, (x4, y4) is the end point, (p x ,p y ) is the pixel size within the drawing window.
[0135] Calculate the direction of the line segment from the starting point to the end point according to the following formula
[0136]
[0137] If the direction With direction satisfy Then determine that the line segment between the first initial coordinate point and the starting point is parallel to the line segment between the starting point and the end point.
[0138] If the direction With direction satisfy Then determine that the line segment between the first initial coordinate point and the end point is parallel to the line segment between the start point and the end point.
[0139] If the direction With direction satisfy Then determine that the first initial coordinate point is on the extension line of the line segment pointing from the starting point to the end point.
[0140] If the direction With direction satisfy Then determine that the first initial coordinate point is on the extension line of the line segment pointing from the end point to the starting point.
[0141] The curve drawing device provided in the embodiment of the present application is described below. The curve drawing device described below and the curve drawing method described above can refer to each other.
[0142] First, combine Figure 4 , introduce the curve drawing device, such as Figure 4 As shown, the curve drawing may include:
[0143] The initial coordinate point determination unit 10 is used to determine the initial coordinate points to be connected that are arranged in sequence;
[0144] The target coordinate point acquisition unit 20 is used to filter the initial coordinate points according to the set filtering rules to obtain the target coordinate points;
[0145] The target curve acquisition unit 30 is used to connect the target coordinate points according to the arrangement order of the target coordinate points to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or the two adjacent target coordinate points on it are not in the same pixel.
[0146] Optionally, the target coordinate point acquisition unit 30 filters the initial coordinate points according to a set filtering rule to obtain the target coordinate points, which may include:
[0147] Combining the initial coordinate points into an ordered sequence in sequence according to the arrangement order of the initial coordinate points;
[0148] In the ordered sequence, the first initial coordinate point is taken as the starting point, and the nearest initial coordinate point that is not in the same pixel as the starting point is determined as the end point, and the initial coordinate points between the starting point and the end point in the ordered sequence are deleted;
[0149] Determine whether the end point is the last initial coordinate point in the ordered sequence;
[0150] If so, taking each initial coordinate point in the ordered sequence as each target coordinate point;
[0151] If not, in the ordered sequence, determine the nearest initial coordinate point after the end point that is not in the same pixel as the end point as the first initial coordinate point, and delete the initial coordinate points in the ordered sequence between the end point and the first initial coordinate point;
[0152] Determine whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0153] If not, taking the end point as a new starting point, taking the first initial coordinate point as a new end point, and returning to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0154] If yes, determine whether the first initial coordinate point is on the extension line of the line segment from the starting point to the end point;
[0155] If yes, delete the end point in the ordered sequence, take the first initial coordinate point as the new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0156] If not, determine the nearest initial coordinate point after the first initial coordinate point that is not in the same pixel as the first initial coordinate point as the second initial coordinate point, and delete the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence;
[0157] Determine whether the first initial coordinate point is on the extension line of the line segment from the end point to the starting point;
[0158] If yes, determine whether the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point;
[0159] If the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point, then delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0160] If the second initial coordinate point is not on the extension line of the line segment from the end point to the first initial coordinate point, determining whether the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point;
[0161] If the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point, then delete the end point in the ordered sequence, take the first initial coordinate point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0162] If the second initial coordinate point is not on the extension line of the line segment from the first initial coordinate point to the end point, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0163] If the first initial coordinate point is not on the extension line of the line segment from the end point to the starting point, determine whether the second initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0164] If yes, delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence;
[0165] If not, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
[0166] Optionally, the process of each target coordinate point acquisition unit 30 determining the nearest initial coordinate point that is not in the same pixel as the starting point may include:
[0167] In the ordered sequence, for each initial coordinate point except the starting point, the square of the pixel distance between the initial coordinate point and the starting point is calculated in turn according to the following formula: Until the calculated square When it is less than 1, the square of the calculated value When it is less than 1, the initial coordinate point corresponding to it is determined as the nearest initial coordinate point that is not in the same pixel as the starting point:
[0168]
[0169] Among them, (x1, y1) is the initial coordinate point other than the starting point, (x2, y2) is the starting point, (p x ,p y ) is the pixel size within the drawing window.
[0170] Optionally, the process in which the target coordinate point acquisition unit 20 determines whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point may include:
[0171] Determine whether a line segment between the first initial coordinate point and the starting point or a line segment between the first initial coordinate point and the end point is parallel to a line segment between the starting point and the end point;
[0172] If yes, then determining that the first initial coordinate point is on the extension line of the line segment between the starting point and the end point;
[0173] If not, it is determined that the first initial coordinate point is not on the extension line of the line segment between the starting point and the end point.
[0174] Optionally, the process of the target coordinate point acquisition unit 30 determining whether the line segment between the first initial coordinate point and the starting point or the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point may include:
[0175] The direction of the line segment from the starting point to the first initial coordinate point is calculated according to the following formula Or, the direction of the line segment from the end point to the first initial coordinate point is calculated according to the following formula:
[0176]
[0177]
[0178] Wherein, (x2, y2) is the starting point, (x3, y3) is the first initial coordinate point, (x4, y4) is the end point, (p x ,p y ) is the pixel size of the drawing window;
[0179] The direction of the line segment from the starting point to the end point is calculated according to the following formula:
[0180] If the direction With the direction satisfy Then determine that the line segment between the first initial coordinate point and the starting point is parallel to the line segment between the starting point and the end point;
[0181] If the direction With the direction satisfy Then, it is determined that the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point.
[0182] The curve drawing apparatus provided in the embodiment of the present application can be applied to curve drawing equipment. Figure 5 The hardware structure diagram of the curve drawing device is shown in FIG. Figure 5 ,The hardware structure of the curve drawing device may include: at least one processor 1, at least one communication interface 2, at least one memory 3 and at least one communication bus 4;
[0183] In the embodiment of the present application, the number of the processor 1, the communication interface 2, the memory 3, and the communication bus 4 is at least one, and the processor 1, the communication interface 2, and the memory 3 communicate with each other through the communication bus 4;
[0184] The processor 1 may be a central processing unit CPU, or an application-specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present invention, etc.;
[0185] The memory 3 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;
[0186] The memory stores a program, and the processor can call the program stored in the memory, wherein the program is used to implement each processing flow in the aforementioned curve drawing solution.
[0187] An embodiment of the present application further provides a storage medium, which can store a program suitable for execution by a processor, wherein the program is used to implement each processing flow in the aforementioned curve drawing solution.
[0188] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0189] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0190] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A curve drawing method, characterized in that: include: Determine the initial coordinate points to be connected in order; Combining the initial coordinate points into an ordered sequence in sequence according to the arrangement order of the initial coordinate points; In the ordered sequence, the first initial coordinate point is taken as the starting point, and the nearest initial coordinate point that is not in the same pixel as the starting point is determined as the end point, and the initial coordinate points between the starting point and the end point in the ordered sequence are deleted; Determine whether the end point is the last initial coordinate point in the ordered sequence; If so, taking each initial coordinate point in the ordered sequence as each target coordinate point; If not, in the ordered sequence, determine the nearest initial coordinate point after the end point that is not in the same pixel as the end point as the first initial coordinate point, and delete the initial coordinate points in the ordered sequence between the end point and the first initial coordinate point; Determine whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point; If not, taking the end point as a new starting point, taking the first initial coordinate point as a new end point, and returning to the step of determining whether the end point is the last initial coordinate point in the ordered sequence; If yes, determine whether the first initial coordinate point is on the extension line of the line segment from the starting point to the end point. If yes, delete the end point in the ordered sequence, use the first initial coordinate point as the new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence. According to the arrangement order of the target coordinate points, the target coordinate points are connected to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or the two adjacent target coordinate points on it are not in the same pixel.
2. The method according to claim 1, characterized in that Also includes: If the first initial coordinate point is not on the extension line of the line segment from the starting point to the end point, then in the ordered sequence, determine the nearest initial coordinate point after the first initial coordinate point that is not in the same pixel as the first initial coordinate point as the second initial coordinate point, and delete the initial coordinate points between the first initial coordinate point and the second initial coordinate point in the ordered sequence; Determine whether the first initial coordinate point is on the extension line of the line segment from the end point to the starting point; If yes, determine whether the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point; If the second initial coordinate point is on the extension line of the line segment from the end point to the first initial coordinate point, then delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence; If the second initial coordinate point is not on the extension line of the line segment from the end point to the first initial coordinate point, determining whether the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point; If the second initial coordinate point is on the extension line of the line segment from the first initial coordinate point to the end point, then delete the end point in the ordered sequence, take the first initial coordinate point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence; If the second initial coordinate point is not on the extension line of the line segment from the first initial coordinate point to the end point, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
3. The method according to claim 2, characterized in that Also includes: If the first initial coordinate point is not on the extension line of the line segment from the end point to the starting point, determining whether the second initial coordinate point is on the extension line of the line segment between the starting point and the end point; If yes, delete the first initial coordinate point in the ordered sequence, take the end point as a new starting point, take the second initial coordinate point as a new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence; If not, the first initial coordinate point is used as a new starting point, the second initial coordinate point is used as a new end point, and the process returns to the step of determining whether the end point is the last initial coordinate point in the ordered sequence.
4. The method according to claim 1, characterized in that: The process of determining the nearest initial coordinate point that is not in the same pixel as the starting point includes: In the ordered sequence, for each initial coordinate point except the starting point, the square of the pixel distance between the initial coordinate point and the starting point is calculated in turn according to the following formula: Until the calculated square When it is less than 1, the square of the calculated value When it is less than 1, the initial coordinate point corresponding to it is determined as the nearest initial coordinate point that is not in the same pixel as the starting point: Among them, (x1, y1) is the initial coordinate point other than the starting point, (x2, y2) is the starting point, (p x ,p y ) is the pixel size within the drawing window.
5. The method according to any one of claims 1 to 4, characterized in that: Determining whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point includes: Determine whether a line segment between the first initial coordinate point and the starting point or a line segment between the first initial coordinate point and the end point is parallel to a line segment between the starting point and the end point; If yes, then determining that the first initial coordinate point is on the extension line of the line segment between the starting point and the end point; If not, it is determined that the first initial coordinate point is not on the extension line of the line segment between the starting point and the end point.
6. The method according to claim 5, characterized in that Determining whether a line segment between the first initial coordinate point and the starting point or a line segment between the first initial coordinate point and the end point is parallel to a line segment between the starting point and the end point includes: The direction of the line segment from the starting point to the first initial coordinate point is calculated according to the following formula Or, the direction of the line segment from the end point to the first initial coordinate point is calculated according to the following formula: Wherein, (x2, y2) is the starting point, (x3, y3) is the first initial coordinate point, (x4, y4) is the end point, (p x ,p y ) is the pixel size of the drawing window; The direction of the line segment from the starting point to the end point is calculated according to the following formula: If the direction With the direction satisfy Then determine that the line segment between the first initial coordinate point and the starting point is parallel to the line segment between the starting point and the end point; If the direction With the direction satisfy Then, it is determined that the line segment between the first initial coordinate point and the end point is parallel to the line segment between the starting point and the end point.
7. A curve drawing device, characterized in that: include: Each initial coordinate point determination unit is used to determine each initial coordinate point to be connected that is arranged in sequence; Each target coordinate point acquisition unit is used to sequentially combine the initial coordinate points into an ordered sequence according to the arrangement order of the initial coordinate points; In the ordered sequence, the first initial coordinate point is taken as the starting point, and the nearest initial coordinate point that is not in the same pixel as the starting point is determined as the end point, and the initial coordinate points between the starting point and the end point in the ordered sequence are deleted; Determine whether the end point is the last initial coordinate point in the ordered sequence; If so, taking each initial coordinate point in the ordered sequence as each target coordinate point; If not, in the ordered sequence, determine the nearest initial coordinate point after the end point that is not in the same pixel as the end point as the first initial coordinate point, and delete the initial coordinate points in the ordered sequence between the end point and the first initial coordinate point; Determine whether the first initial coordinate point is on the extension line of the line segment between the starting point and the end point; If not, taking the end point as a new starting point, taking the first initial coordinate point as a new end point, and returning to the step of determining whether the end point is the last initial coordinate point in the ordered sequence; If yes, determine whether the first initial coordinate point is on the extension line of the line segment from the starting point to the end point. If yes, delete the end point in the ordered sequence, use the first initial coordinate point as the new end point, and return to the step of determining whether the end point is the last initial coordinate point in the ordered sequence. A target curve acquisition unit is used to connect the target coordinate points according to the arrangement order of the target coordinate points to obtain a target curve, wherein the target curve is composed of a plurality of line segments. At the pixel level, the line segment between two adjacent target coordinate points passes through the initial coordinate points between the two adjacent target coordinate points. For each line segment, it satisfies: the number of target coordinate points on it is less than or equal to the number of initial coordinate points on it, and / or the two adjacent target coordinate points on it are not in the same pixel.
8. A curve drawing device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the curve drawing method as described in any one of claims 1-6.
9. A readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the curve drawing method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Method and system for identifying curve
CN114863438A
Curve generation method and system, computer equipment and storage medium
CN115082592A