CN112233202B - Regular polygon drawing method and device, electronic equipment and readable storage medium - Google Patents

Regular polygon drawing method and device, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN112233202B
CN112233202B CN201910636810.9A CN201910636810A CN112233202B CN 112233202 B CN112233202 B CN 112233202B CN 201910636810 A CN201910636810 A CN 201910636810A CN 112233202 B CN112233202 B CN 112233202B
Authority
CN
China
Prior art keywords
regular polygon
graph
sides
width
height
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910636810.9A
Other languages
Chinese (zh)
Other versions
CN112233202A (en
Inventor
陈志宝
吴增谂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Original Assignee
Beijing Kingsoft Office Software Inc
Zhuhai Kingsoft Office Software Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Kingsoft Office Software Inc, Zhuhai Kingsoft Office Software Co Ltd filed Critical Beijing Kingsoft Office Software Inc
Priority to CN201910636810.9A priority Critical patent/CN112233202B/en
Publication of CN112233202A publication Critical patent/CN112233202A/en
Application granted granted Critical
Publication of CN112233202B publication Critical patent/CN112233202B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/20Drawing from basic elements, e.g. lines or circles

Abstract

The embodiment of the invention provides a regular polygon drawing method, a regular polygon drawing device, electronic equipment and a readable storage medium. The method comprises the following steps: determining the number of edges of a first graph drawn by a user through a regular polygon tool; obtaining the radius of a circle to be circumscribed of the first graph; based on the number of sides and the radius, calculating the height and the width of a regular polygon which can be externally connected to a circle and meet the number of sides; using the number of sides, height and width, a regular polygon is determined and displayed. By applying the regular polygon drawing method provided by the embodiment of the invention, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, and the user experience is improved.

Description

Regular polygon drawing method and device, electronic equipment and readable storage medium
Technical Field
The present invention relates to the field of document processing technologies, and in particular, to a method and apparatus for drawing a regular polygon, an electronic device, and a readable storage medium.
Background
Currently, users often need to draw regular polygons using drawing tools in office software. Wherein the regular polygon is a polygon with all angles equal and all sides equal. For example, a user needs to draw a regular hexagon that can circumscribe a circle using a drawing tool.
However, when the user wants to draw a regular hexagon that can circumscribe the circle, the user needs to first select the regular hexagon tool from the drawing tools. Then, a pattern that looks like a regular hexagon to the naked eye is drawn using a regular hexagon tool. Wherein the pattern is hexagonal instead of regular hexagonal. The user then needs to rely on the naked eye or an auxiliary means (e.g., ruler measurement) to slowly adjust the pattern to a regular hexagon and allow the regular hexagon to circumscribe the circle. Therefore, the method for drawing the regular polygon is time-consuming and labor-consuming, so that the user experience is not good.
Disclosure of Invention
The embodiment of the invention aims to provide a regular polygon drawing method, a regular polygon drawing device, electronic equipment and a readable storage medium, so that regular polygons which can be externally connected with a circle can be simply and quickly drawn, and the user experience is improved. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present invention provides a method for drawing a regular polygon, including:
determining the number of edges of a first graph drawn by a user through a regular polygon tool;
obtaining the radius of a circle to be circumscribed of the first graph;
based on the number of sides and the radius, calculating the height and the width of a regular polygon which can be externally connected to a circle and meet the number of sides;
using the number of sides, height and width, a regular polygon is determined and displayed.
Optionally, the step of obtaining the radius of the circle to be circumscribed by the first graph may include:
displaying a radius input box;
and determining the numerical value input to the radius input box by the user as the radius of the circle to be circumscribed by the first graph.
Optionally, the step of calculating the height and the width of the regular polygon which can be circumscribed to the circle and satisfy the number of sides based on the number of sides and the radius may include:
inputting the number of sides and the radius into a height calculation formula, and calculating the height of a regular polygon which can be externally connected to a circle and meets the number of sides;
when the edge number is an odd number, inputting the edge number and the radius into a first width calculation formula, and calculating the width of the regular polygon;
when the number of sides is even, the number of sides, the radius and the height are input into a second width calculation formula, and the width of the regular polygon is calculated.
Alternatively, in the embodiment of the present invention, the height calculation formula may be:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of a regular polygon, w 1 Is the width of regular polygon when the number of sides is odd, w 2 The width of the regular polygon when the number of the edges is even; r is the radius of the circle, n is the number of edges of the first graph, mod is the remainder operator.
Optionally, when the number of sides is even, the step of determining and displaying the regular polygon using the number of sides, the height and the width may include:
under the condition of keeping the edge number of the first graph unchanged, adjusting the width and the height of the first graph by utilizing the height and the width to obtain a second graph;
setting the side length of each side of the second graph to be equal and the angle of each vertex angle of the second graph to be equal under the condition of keeping the side number and the width and the height of the second graph unchanged, so as to obtain a regular polygon;
the first pattern is replaced with a regular polygon.
Optionally, the step of setting the side lengths of the sides of the second graph to be equal and setting the vertex angles of the second graph to be equal to obtain a regular polygon may include:
searching adjusting point parameter information with a mapping relation with the edge number in a preset mapping table; the adjusting point parameter information is parameter information for adjusting the second graph to be a regular polygon;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so that the side lengths of the sides of the second graph are equal and the angle of each vertex angle of the second graph is equal, and obtaining a regular polygon.
Optionally, in an embodiment of the present invention, a preset mapping table records:
a mapping relation between the edge number six and the first adjusting point parameter information, and a mapping relation between the edge number eight and the second adjusting point parameter information; the first adjusting point parameter information is as follows:
the second adjusting point parameter information is:
in a second aspect, an embodiment of the present invention further provides a regular polygon drawing apparatus, including:
the first determining module is used for determining the number of edges of a first graph drawn by a user through the regular polygon tool;
the obtaining module is used for obtaining the radius of the circle to be circumscribed of the first graph;
the calculating module is used for calculating the height and the width of the regular polygon which can be externally connected with the circle and meet the edge number based on the edge number and the radius;
and the second determining module is used for determining and displaying the regular polygon by using the edge number, the height and the width.
Optionally, in an embodiment of the present invention, the obtaining module includes:
a display unit for displaying the radius input frame;
and the determining unit is used for determining the numerical value input to the radius input box by the user as the radius of the circle to be circumscribed by the first graph.
Alternatively, in an embodiment of the present invention, the calculation module may include:
inputting the number of sides and the radius into a height calculation formula, and calculating the height of a regular polygon which can be externally connected to a circle and meets the number of sides;
when the edge number is an odd number, inputting the edge number and the radius into a first width calculation formula, and calculating the width of the regular polygon;
when the number of sides is even, the number of sides, the radius and the height are input into a second width calculation formula, and the width of the regular polygon is calculated.
Optionally, in an embodiment of the present invention, the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of a regular polygon, w 1 Is the width of regular polygon when the number of sides is odd, w 2 The width of the regular polygon when the number of the edges is even; r is the radius of the circle, n is the number of edges of the first graph, mod is the remainder operator.
Optionally, in an embodiment of the present invention, when the number of edges is an even number, the second determining module includes:
the adjusting unit is used for adjusting the width and the height of the first graph by utilizing the height and the width under the condition of keeping the edge number of the first graph unchanged, so as to obtain a second graph;
the setting unit is used for setting the side lengths of the sides of the second graph to be equal and setting the angle of each vertex angle of the second graph to be equal under the condition of keeping the number of the sides and the width and the height of the second graph unchanged, so as to obtain a regular polygon;
and a replacing unit for replacing the first pattern with a regular polygon.
Optionally, in an embodiment of the present invention, the setting unit is specifically configured to:
searching adjusting point parameter information with a mapping relation with the edge number in a preset mapping table; the adjusting point parameter information is parameter information for adjusting the second graph to be a regular polygon;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so that the side lengths of the sides of the second graph are equal and the angle of each vertex angle of the second graph is equal, and obtaining a regular polygon.
Optionally, in the embodiment of the present invention, the preset mapping table may record:
a mapping relation between the edge number six and the first adjusting point parameter information, and a mapping relation between the edge number eight and the second adjusting point parameter information;
the first adjusting point parameter information is as follows:
the second adjusting point parameter information is:
in a third aspect, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of the first aspects when executing a program stored on a memory.
In a fourth aspect, embodiments of the present invention also provide a readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method steps of any of the first aspects.
In a fifth aspect, embodiments of the present invention also provide a computer program product comprising instructions which, when run on an electronic device, cause the electronic device to perform the method steps of any of the first aspects. In the embodiment of the invention, the edge number of the first graph drawn by the user through the regular polygon tool can be determined first. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
Drawings
In order to more clearly illustrate the embodiments of the invention or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the invention, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a regular polygon drawing method according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a first pattern according to an embodiment of the present invention;
fig. 3 is a schematic diagram of a height h and a width w of a regular hexagon according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of an adjustment point according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a regular polygon drawing device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In order to solve the technical problems in the related art, the embodiment of the invention provides a regular polygon drawing method, a regular polygon drawing device, electronic equipment and a readable storage medium.
The electronic device may execute the method steps of the regular polygon drawing method provided by the embodiment of the present invention. Including but not limited to computers, smart phones, and smart wearable devices.
In addition, office software may be installed in the electronic device, and a user may draw graphics through a drawing tool in the office software. The office software includes, but is not limited to: word software, PPT (PowerPoint) software, and WPS (WPS software) software.
Referring to fig. 1, the regular polygon drawing method provided by the embodiment of the present invention may include the following steps:
s101: determining the number of edges of a first graph drawn by a user through a regular polygon tool;
when a user wants to draw a regular hexagon which can be circumscribed with a circle, the user can draw a first graph by using a regular hexagon tool. For example, a first graph as shown in fig. 2 may be drawn.
However, when the user selects the regular hexagon tool and draws the regular hexagon by dragging the mouse, the drawing is usually a hexagon instead of a regular hexagon. That is, in this example, the first graphic drawn is typically a non-regular six-sided polygon. Of course, it is also reasonable that the first pattern drawn may also be a regular hexagon.
In addition, it can be appreciated that the mapping relationship between the regular polygon tool and the edge number can be recorded in the electronic device. Thus, after the user draws the first graph through the regular polygon tool, the electronic device can determine the number of sides corresponding to the regular polygon tool according to the mapping relation. And the number of sides corresponding to the regular polygon tool is consistent with that of the first graph, so that the electronic equipment can determine the number of sides of the first graph.
Of course, a graphical edge number input box may also be displayed. Thus, the user can input the edge number of the first graph in the graph edge number input box, so that the electronic device can obtain the edge number of the first graph. In addition, the number of sides of the first graph can be determined by using any mode of determining the number of sides of the first graph drawn by the regular polygon tool in the related technology, which is also reasonable.
In addition, before determining the number of sides of the first graphic, it may also be determined whether the first graphic is a graphic drawn by the regular polygon tool. And, when the first graphic is a graphic drawn by the regular polygon tool, the number of sides of the first graphic can be determined in the above manner. In this way, the number of sides of the graphic drawn by the regular polygon tool can be determined.
When the first graphic is not a graphic drawn by the regular polygon tool, it is difficult for the electronic device to determine whether the graphic drawn at will by the user is a polygon or the number of sides of the polygon. In this case, the electronic device may also obtain the number of sides of the graphic drawn by the user by displaying the graphic number of sides input box and reading the numerical value in the graphic number of sides input box.
S102: obtaining the radius of a circle to be circumscribed of the first graph;
wherein the electronic device may display a radius input box. The user may enter a circular radius within the radius input box at which the user wants the first graphic to circumscribe (i.e., to circumscribe). Wherein the radius of the circle may be any value. The electronic device may then determine the value within the radius input box as the radius of the circle to be circumscribed by the first graphic.
S103: based on the number of sides and the radius, calculating the height and the width of a regular polygon which can be externally connected to a circle and meet the number of sides;
for example, the obtained circle may be a circle having a radius r as shown in fig. 3, and in addition, the number of sides of the first pattern is n=6. Then, the height h and the width w of a positive n-sided polygon that can circumscribe a circle of radius r can be determined based on the radius r and the number of sides n. Wherein the height h and width w of the positive n-sided polygon can be seen in fig. 3. As can be seen from fig. 3, the height of the regular n-sided shape (i.e., regular hexagon) may be the height of the circumscribed rectangle of the regular hexagon as shown in the drawing, and the width of the regular n-sided shape (i.e., regular hexagon) may be the height of the circumscribed rectangle of the regular hexagon as shown in the drawing.
The height and width of a regular polygon that can circumscribe a circle can be calculated as follows:
the number of edges and the radius may be input to the height calculation formula. Then, the height of a regular polygon which can circumscribe the circle and satisfy the number of sides is calculated. Thus, the height of the regular polygon which can be circumscribed to the circle and satisfies the number of sides can be calculated directly based on the height calculation formula. The height calculation formula is as follows:
after calculating the height, it may be determined whether the number of sides of the first pattern is an even number. When the number of sides is an odd number, the number of sides and the radius may be input to the first width calculation formula to calculate the width of the regular polygon. Thus, the height of the regular polygon which can be circumscribed to the circle and satisfies the odd number of sides can be calculated directly based on the first width calculation formula. The first width calculation formula is as follows:
when the number of sides is an even number, the number of sides, the radius, and the height may be input to the second width calculation formula to calculate the width of the regular polygon. Thus, the height of the regular polygon which can be circumscribed to the circle and satisfies the odd number of sides can be calculated directly based on the second width calculation formula. Wherein, the second width calculation formula is:
wherein h is the height of a regular polygon, w 1 The width w of the regular polygon calculated when the number of the edges is odd 2 The width of the regular polygon is calculated when the number of the edges is even; r is the radius of the circle, n is the number of edges of the first graph, mod is the remainder operator.
The height and width of the regular polygon which is externally connected with the circle and meets the requirement of the number of sides can be simply and quickly calculated.
S104: using the number of sides, height and width, a regular polygon is determined and displayed.
It will be appreciated that since the height and width are calculated as wide heights of polygons that can circumscribe the circle. Thus, the first pattern may be adjusted to conform to the height and width patterns. Then, the respective vertex angles of the first pattern may be adjusted to be equal based on the number of sides of the first pattern, so that a regular polygon that can be circumscribed to the circle may be obtained.
When the number of the obtained edges is determined to be even, the regular polygon can be determined specifically by the following method:
the width and height of the first pattern are adjusted by using the height and width while maintaining the number of sides of the first pattern unchanged. That is, the width and height of the first pattern are adjusted to be a width and height that satisfies the height and width, thereby obtaining the second pattern.
Then, while maintaining the number of sides and the width and height of the second pattern unchanged, the side lengths of the sides of the second pattern are set to be equal and the angle of the top corners of the second pattern is set to be equal, resulting in a regular polygon.
The method for obtaining the regular polygon by setting the side lengths of the sides of the second graph to be equal and setting the angles of the top corners of the second graph to be equal can be as follows:
and searching the parameter information of the adjusting points with the mapping relation with the edge number in the preset mapping table. The adjusting point parameter information is parameter information for adjusting the second graph to be regular polygon. And then, adjusting the adjusting points of the second graph according to the adjusting point parameter information so that the side lengths of the sides of the second graph are equal and the angle of each vertex angle of the second graph is equal, thereby obtaining the regular polygon.
The preset mapping table may specifically record: the mapping relationship between the number of sides six and the first adjustment point parameter information, and the mapping relationship between the number of sides eight and the second adjustment point parameter information are, of course, not limited thereto. The first adjusting point parameter information is parameter information for adjusting the hexagon to be a regular hexagon. The second adjustment point parameter information is parameter information for adjusting the octagon to the regular octagon.
The first adjusting point parameter information is as follows:
the second adjusting point parameter information is:
the following describes the adjustment points provided in the embodiments of the present invention:
referring to fig. 4, the position of the upper left corner of the hexagon shown in fig. 4 is provided with an adjustment point. And the position of the adjusting point changes along with the change of the parameter information of the adjusting point. When the parameter information of the adjustment point of the second graph is set to 0.25/cos30 °, the adjustment point of the hexagon may be located at a quarter of the long side of the rectangular dashed frame shown in fig. 4, that is, the distance from the position of the adjustment point to the wide side of the rectangular dashed frame is a quarter of the long side.
The adjustment point shown in fig. 4 may be moved left and right on the long side of the rectangular dashed frame where the adjustment point parameter information is located (where the rightmost point may be moved to the center of the long side) when the value of the adjustment point parameter information is changed. When the adjusting point moves leftwards by a preset distance, the point at the lower left vertex angle of the hexagon also moves leftwards by a preset distance, and the point at the upper right vertex angle and the point at the lower right vertex angle of the hexagon move rightwards by a preset distance horizontally. In addition, when the adjustment point moves rightward by a preset distance, the point of the lower left vertex angle of the hexagon also moves horizontally rightward by a preset distance, and the point of the upper right vertex angle and the point of the lower right vertex angle of the hexagon move horizontally leftward by a preset distance.
It will be appreciated that after the regular polygon is obtained, the first pattern may be replaced with a regular polygon. Thus, a regular polygon which can circumscribe the circle and has the same number of sides as the first pattern can be displayed. Of course, the regular polygon may be displayed at a position where the first graphic is not coincident, so that the first graphic drawn by the user may be retained, and a regular polygon which can be circumscribed to the circle and has the same number of sides as the first graphic may be obtained.
In the embodiment of the invention, the edge number of the first graph drawn by the user through the regular polygon tool can be determined first. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
In conclusion, by applying the regular polygon drawing scheme provided by the embodiment of the invention, the regular polygon which can be externally connected with the round shape can be simply and quickly drawn, and the user experience is improved.
Corresponding to the above method embodiment, the embodiment of the present invention further provides a regular polygon drawing device, see fig. 5, including:
a first determining module 501, configured to determine the number of edges of a first graphic drawn by a user through a regular polygon tool;
an obtaining module 502, configured to obtain a radius of a circle to be circumscribed by the first graphic;
a calculating module 503, configured to calculate, based on the number of sides and the radius, a height and a width of a regular polygon that can be circumscribed to a circle and satisfy the number of sides;
a second determining module 504, configured to determine and display a regular polygon using the number of sides, the height and the width.
By applying the device provided by the embodiment of the invention, the edge number of the first graph drawn by the user through the regular polygon tool can be determined. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
Optionally, in an embodiment of the present invention, the obtaining module 502 includes:
a display unit for displaying the radius input frame;
and the determining unit is used for determining the numerical value input to the radius input box by the user as the radius of the circle to be circumscribed by the first graph.
Alternatively, in an embodiment of the present invention, the calculating module 503 may include:
inputting the number of sides and the radius into a height calculation formula, and calculating the height of a regular polygon which can be externally connected to a circle and meets the number of sides;
when the edge number is an odd number, inputting the edge number and the radius into a first width calculation formula, and calculating the width of the regular polygon;
when the number of sides is even, the number of sides, the radius and the height are input into a second width calculation formula, and the width of the regular polygon is calculated.
Optionally, in an embodiment of the present invention, the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of a regular polygon, w 1 Is the width of regular polygon when the number of sides is odd, w 2 The width of the regular polygon when the number of the edges is even; r is the radius of the circle, n is the number of edges of the first graph, mod is the remainder operator.
Optionally, in an embodiment of the present invention, when the number of edges is even, the second determining module 504 includes:
the adjusting unit is used for adjusting the width and the height of the first graph by utilizing the height and the width under the condition of keeping the edge number of the first graph unchanged, so as to obtain a second graph;
the setting unit is used for setting the side lengths of the sides of the second graph to be equal and setting the angle of each vertex angle of the second graph to be equal under the condition of keeping the number of the sides and the width and the height of the second graph unchanged, so as to obtain a regular polygon;
and a replacing unit for replacing the first pattern with a regular polygon.
Optionally, in an embodiment of the present invention, the setting unit is specifically configured to:
searching adjusting point parameter information with a mapping relation with the edge number in a preset mapping table; the adjusting point parameter information is parameter information for adjusting the second graph to be a regular polygon;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so that the side lengths of the sides of the second graph are equal and the angle of each vertex angle of the second graph is equal, and obtaining a regular polygon.
Optionally, in the embodiment of the present invention, the preset mapping table may record:
a mapping relation between the edge number six and the first adjusting point parameter information, and a mapping relation between the edge number eight and the second adjusting point parameter information;
the first adjusting point parameter information is as follows:
the second adjusting point parameter information is:
corresponding to the above-mentioned method embodiment, the embodiment of the present invention further provides an electronic device, referring to fig. 6, including a processor 601, a communication interface 602, a memory 603, and a communication bus 604, where the processor 601, the communication interface 602, and the memory 603 complete communication with each other through the communication bus 604;
a memory 603 for storing a computer program;
the processor 601 is configured to implement the method steps of any one of the above-described regular polygon rendering methods when executing the program stored in the memory 603.
In the embodiment of the invention, the electronic device can firstly determine the number of edges of the first graph drawn by the user through the regular polygon tool. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
Corresponding to the above method embodiments, the present invention further provides a readable storage medium, in which a computer program is stored, which when executed by a processor, implements the method steps of any one of the above regular polygon rendering methods.
After the computer program stored in the readable storage medium provided by the embodiment of the invention is executed by the processor of the electronic device, the electronic device can firstly determine the number of edges of the first graph drawn by the user through the regular polygon tool. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
Corresponding to the above method embodiments, the present invention also provides a computer program product, which when run on an electronic device, causes the electronic device to perform: the method steps of any one of the regular polygon drawing methods.
After the computer program product provided by the embodiment of the invention is executed by the processor of the electronic device, the electronic device can firstly determine the number of sides of the first graph drawn by the user through the regular polygon tool. Then, the radius of the circle to be circumscribed by the first pattern may be obtained. Then, based on the number of sides and the radius, the height and width of a regular polygon that can circumscribe the circle and satisfy the number of sides can be calculated. The regular polygon may then be determined and displayed using the number of sides, the height, and the width. Therefore, the regular polygon which can be externally connected with the circle can be simply and quickly drawn, so that a user does not need to rely on naked eyes or auxiliary means to adjust the graph to be the regular hexagon, and the experience of the user is improved.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
In the above embodiments, it may be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, produces a flow or function in accordance with embodiments of the present invention, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a computer network, or other programmable apparatus. The computer instructions may be stored in or transmitted from one computer-readable storage medium to another, for example, by wired (e.g., coaxial cable, optical fiber, digital Subscriber Line (DSL)), or wireless (e.g., infrared, wireless, microwave, etc.). The computer readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. that contains an integration of one or more available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid State Disk (SSD)), etc.
It is noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
In this specification, each embodiment is described in a related manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for apparatus, electronic devices, readable storage media and computer program product embodiments, the description is relatively simple as it is substantially similar to method embodiments, as relevant points are found in the partial description of method embodiments.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (9)

1. A regular polygon drawing method, characterized by comprising:
determining the number of edges of a first graph drawn by a user through a regular polygon tool;
obtaining the radius of a circle to be circumscribed of the first graph;
calculating the height and width of a regular polygon which can be circumscribed to the circle and satisfies the number of sides based on the number of sides and the radius;
determining and displaying the regular polygon with the even number of sides by using the number of sides, the height and the width;
wherein said determining and displaying said regular polygon with said number of sides being an even number using said number of sides, said height and said width comprises:
under the condition that the edge number of the first graph is kept unchanged, adjusting the width and the height of the first graph by utilizing the height and the width to obtain a second graph;
setting the side lengths of the sides of the second graph to be equal and setting the angle of each vertex angle of the second graph to be equal under the condition that the number of sides and the width and the height of the second graph are kept unchanged, so as to obtain the regular polygon;
and replacing the first graph by the regular polygon.
2. The method of claim 1, wherein the step of obtaining the radius of the circle to be circumscribed by the first graphic comprises:
displaying a radius input box;
and determining the numerical value input to the radius input box by the user as the radius of the circle to be circumscribed by the first graph.
3. The method of claim 1, wherein the step of calculating a height and a width of a regular polygon that can circumscribe the circle and satisfy the number of sides based on the number of sides and the radius, comprises:
inputting the edge number and the radius into a height calculation formula, and calculating the height of a regular polygon which can be externally connected with the circle and meets the edge number;
when the edge number is an odd number, inputting the edge number and the radius into a first width calculation formula, and calculating the width of the regular polygon;
and when the edge number is even, inputting the edge number, the radius and the height into a second width calculation formula to calculate the width of the regular polygon.
4. A method according to claim 3, wherein the height calculation formula is:
the first width calculation formula is:
the second width calculation formula is:
wherein h is the height of the regular polygon, and w is 1 The width of the regular polygon when the number of the edges is odd, and the w is as follows 2 The width of the regular polygon when the number of the edges is even; the r is the radius of the circle, the n is the edge number of the first graph, and the mod is a remainder operator.
5. The method of claim 1, wherein the step of setting the side lengths of the sides of the second pattern equal and the vertex angles of the second pattern equal results in the regular polygon, comprises:
searching adjusting point parameter information with a mapping relation with the edge number in a preset mapping table; the adjusting point parameter information is parameter information for adjusting the second graph to be a regular polygon;
and adjusting the adjusting points of the second graph according to the adjusting point parameter information so that the side lengths of the sides of the second graph are equal and the angles of the top angles of the second graph are equal, thereby obtaining the regular polygon.
6. The method of claim 5, wherein the preset mapping table includes:
a mapping relation between the edge number six and the first adjusting point parameter information, and a mapping relation between the edge number eight and the second adjusting point parameter information; the first adjusting point parameter information is as follows:
the second adjusting point parameter information is:
7. a regular polygon drawing apparatus, characterized by comprising:
the first determining module is used for determining the number of edges of a first graph drawn by a user through the regular polygon tool;
the obtaining module is used for obtaining the radius of the circle to be circumscribed of the first graph;
a calculation module for calculating a height and a width of a regular polygon which can be circumscribed to the circle and satisfies the number of sides based on the number of sides and the radius;
a second determining module, configured to determine and display the regular polygon with the even number of sides by using the number of sides, the height and the width;
wherein the second determining module includes:
the adjusting unit is used for adjusting the width and the height of the first graph by utilizing the height and the width under the condition of keeping the edge number of the first graph unchanged, so as to obtain a second graph;
the setting unit is used for setting the side lengths of the sides of the second graph to be equal and setting the angle of each vertex angle of the second graph to be equal under the condition of keeping the number of the sides and the width and the height of the second graph unchanged, so as to obtain a regular polygon;
and a replacing unit for replacing the first pattern with a regular polygon.
8. The electronic equipment is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are communicated with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any one of claims 1-6 when executing a program stored on a memory.
9. A readable storage medium, characterized in that it has stored therein a computer program which, when executed by a processor, implements the method steps of any of claims 1-6.
CN201910636810.9A 2019-07-15 2019-07-15 Regular polygon drawing method and device, electronic equipment and readable storage medium Active CN112233202B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910636810.9A CN112233202B (en) 2019-07-15 2019-07-15 Regular polygon drawing method and device, electronic equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910636810.9A CN112233202B (en) 2019-07-15 2019-07-15 Regular polygon drawing method and device, electronic equipment and readable storage medium

Publications (2)

Publication Number Publication Date
CN112233202A CN112233202A (en) 2021-01-15
CN112233202B true CN112233202B (en) 2023-09-19

Family

ID=74111185

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910636810.9A Active CN112233202B (en) 2019-07-15 2019-07-15 Regular polygon drawing method and device, electronic equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN112233202B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0344768A (en) * 1989-07-13 1991-02-26 Minolta Camera Co Ltd Graphic drawing method for graphic processor
JP2001067485A (en) * 1999-08-27 2001-03-16 Digital Electronics Corp Device and method for drawing polygon, and computer- readable recording medium where for program drawing polygon is recorded
JP2001357409A (en) * 2000-06-13 2001-12-26 Canon Inc Picture processor, picture processing method and storage medium
US6556215B1 (en) * 1999-07-16 2003-04-29 Kabushiki Kaisha Sega Enterprises Image processing device and method thereof, game device and method thereof, and recording medium recorded image processing program or game program operated on a computer
KR20030042618A (en) * 2001-11-23 2003-06-02 이경희 Character and graphic image editing method of cutting plotter with computer
JP2009269386A (en) * 2008-05-07 2009-11-19 Koichi Tamura Multifunctional ruler
CN101719057A (en) * 2009-11-27 2010-06-02 广东威创视讯科技股份有限公司 Method and device for drawing geometric figures
JP2011017841A (en) * 2009-07-08 2011-01-27 Ricoh Co Ltd Drawing apparatus and drawing method
CN103065344A (en) * 2012-11-30 2013-04-24 贵州电网公司六盘水供电局 Drawing method of two dimensional graph
CN103617282A (en) * 2013-12-10 2014-03-05 北京捷泰天域信息技术有限公司 Interest point attribute displaying method based on regular polygon tessellation

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8704837B2 (en) * 2004-04-16 2014-04-22 Apple Inc. High-level program interface for graphics operations

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH0344768A (en) * 1989-07-13 1991-02-26 Minolta Camera Co Ltd Graphic drawing method for graphic processor
US6556215B1 (en) * 1999-07-16 2003-04-29 Kabushiki Kaisha Sega Enterprises Image processing device and method thereof, game device and method thereof, and recording medium recorded image processing program or game program operated on a computer
JP2001067485A (en) * 1999-08-27 2001-03-16 Digital Electronics Corp Device and method for drawing polygon, and computer- readable recording medium where for program drawing polygon is recorded
JP2001357409A (en) * 2000-06-13 2001-12-26 Canon Inc Picture processor, picture processing method and storage medium
KR20030042618A (en) * 2001-11-23 2003-06-02 이경희 Character and graphic image editing method of cutting plotter with computer
JP2009269386A (en) * 2008-05-07 2009-11-19 Koichi Tamura Multifunctional ruler
JP2011017841A (en) * 2009-07-08 2011-01-27 Ricoh Co Ltd Drawing apparatus and drawing method
CN101719057A (en) * 2009-11-27 2010-06-02 广东威创视讯科技股份有限公司 Method and device for drawing geometric figures
CN103065344A (en) * 2012-11-30 2013-04-24 贵州电网公司六盘水供电局 Drawing method of two dimensional graph
CN103617282A (en) * 2013-12-10 2014-03-05 北京捷泰天域信息技术有限公司 Interest point attribute displaying method based on regular polygon tessellation

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
谭毓澄等.CAD教学中绘制正多边形的教学对策研究.《九江学院学报》.2009,(第3期),第54-56页. *

Also Published As

Publication number Publication date
CN112233202A (en) 2021-01-15

Similar Documents

Publication Publication Date Title
CN109753641B (en) Method and device for changing object position, electronic equipment and storage medium
US9400597B2 (en) Presenting dynamic grids
CN109741287B (en) Image-oriented filtering method and device
CN108564645B (en) Rendering method of house model, terminal device and medium
US20160012025A1 (en) Web page display method and device
US9977581B2 (en) Selection refinement tool
CN112233202B (en) Regular polygon drawing method and device, electronic equipment and readable storage medium
CN111428430B (en) Method, device, equipment and medium for acquiring circuit device information in circuit design
US10366518B2 (en) Extension of text on a path
CN111339730B (en) Method and device for checking device position in PCB design
US8904314B1 (en) RC extraction for multiple patterning layout design
CN111625679A (en) Method and device for generating video story line
CN111951349B (en) Method and device for adjusting graph vertex types and electronic equipment
CN111698548B (en) Video playing method and device
CN109165648B (en) Image processing method, image processing device and mobile terminal
CN112987992B (en) Navigation element display method and device and electronic equipment
US11836897B2 (en) Table shifting and skewing
CN112837394A (en) Polygon drawing method and device, electronic equipment and readable storage medium
CN110019492B (en) Information display method and device
CN112784526A (en) Document page adjusting method and device
CN111696169A (en) Method and device for generating equilateral polygon and electronic equipment
CN111897661A (en) Method and device for copying cell contents in spreadsheet and electronic equipment
CN112783383A (en) File display method, device and equipment
CN112785638A (en) Graph processing method and device
JP7350899B2 (en) Document element alignment method and apparatus, electronic device, and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant