A graphics processing method and device
By calculating and moving the coordinates of the circle, it is possible to quickly adjust the two circles to the inner tangent state in office software, solving the time-consuming and labor-intensive problem of manual adjustment in the prior art, and improving the user experience.
Patent Information
- Application Number
- CN202010000936.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-01-02
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-01-02
AI Technical Summary
When users use office software drawing tools, they need to manually adjust the two circles to make them tangential, which is time-consuming and labor-intensive, and has poor user experience.
The graphics processing process is simplified by determining the coordinates of the two circles, calculating the center coordinates of the second circle when they are tangent, and moving the second circle to achieve inner tangent.
It realizes rapid and simple adjustment of the two circles to the inner tangent state, improving user experience and reducing operating time and energy.
Smart Images

Figure CN112785638B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of document processing, and in particular to a graphic processing method and device. Background Art
[0002] Currently, users often need to use drawing tools in office software to draw graphics and need to process the drawn graphics. For example, when a teacher makes a courseware, he needs to move two drawn circles so that the outer side of one circle is tangent to the inner side of the other circle, that is, the two circles are tangent to each other.
[0003] However, the user needs to spend a lot of time and energy to manually adjust the positions of the two graphics so that the two circles are tangent to each other. It can be seen that this graphics processing method is time-consuming and labor-intensive, resulting in a poor user experience. Summary of the invention
[0004] The purpose of the embodiment of the present invention is to provide a graphics processing method and device, so as to simply and quickly realize the inner tangency of a circle, thereby improving the user experience. The specific technical solution is as follows:
[0005] In a first aspect, an embodiment of the present invention provides a graphics processing method, which may include:
[0006] Determine a first circle and a second circle selected by a user in the document;
[0007] Obtain a first coordinate of the center of the first circle and a second coordinate of the center of the second circle;
[0008] Using the first coordinate and the second coordinate, calculate the third coordinate of the center of the second circle when the first circle is tangent to the second circle;
[0009] The second circle is moved so that the coordinates of the center of the second circle after the movement are the third coordinates.
[0010] Optionally, determining the first circle and the second circle selected by the user in the document may include:
[0011] Determine the two circles selected by the user in the document;
[0012] The circle with a larger radius of the two circles is determined as the first circle that keeps the same position, and the circle with a smaller radius of the two circles is determined as the second circle to be moved.
[0013] Optionally, obtaining the first coordinate of the center of the first circle and the second coordinate of the center of the second circle may include:
[0014] Obtain the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the first radius of the first circle;
[0015] Calculate the first coordinates of the center of the first circle using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the first radius;
[0016] Get the coordinates of the upper left corner vertex of the second circumscribed rectangle of the second circle and the second radius of the second circle;
[0017] The second coordinates of the center of the second circle are calculated using the coordinates of the upper left corner of the second circumscribed rectangle and the second radius.
[0018] Optionally, calculating the third coordinate of the center of the second circle when the first circle is tangent to the second circle according to the first coordinate and the second coordinate may include:
[0019] When the difference between the abscissa of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the abscissa of the coordinates of the upper left corner vertex of the second circumscribed rectangle is zero, and the difference between the ordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the ordinate of the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero, determine that the angle formed by the straight line where the centers of the first circle and the second circle are located and the abscissa of the rectangular coordinate system is 90° or 270°;
[0020] When the difference between the abscissa of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is not zero, and the difference between the ordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero, the angle formed by the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system is calculated using the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the coordinates of the upper left corner vertex of the second circumscribed rectangle of the second circle;
[0021] Calculate the absolute value of the difference between the first radius and the second radius as the center point distance between the center of the first circle and the center of the second circle when the first circle and the second circle are tangent to each other;
[0022] Calculate the coordinates of the upper left corner of the third circumscribed rectangle of the second circle when the first circle is tangent to the second circle by using the distance between the center points, the angle, the second radius of the second circle and the coordinates of the upper left corner of the first circumscribed rectangle of the first circle;
[0023] The third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle are calculated using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
[0024] Optionally, using the center point distance, the included angle, the second radius of the second circle, and the upper left corner vertex coordinates of the first circumscribed rectangle of the first circle, calculating the upper left corner vertex coordinates of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle includes:
[0025] Substitute the center point distance, the included angle, the radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle into a preset calculation formula to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle;
[0026] The preset calculation formulas include:
[0027] X2=d×sinα-r2+x1
[0028] Y2=d×cosα-r2+y1
[0029] Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle.
[0030] In a second aspect, an embodiment of the present invention further provides a graphics processing device, which may include:
[0031] A determination module, for a first circle and a second circle selected by a user in a document;
[0032] An obtaining module, used for obtaining a first coordinate of a center point of the first circle and a second coordinate of a center point of the second circle;
[0033] A calculation module, used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the second circle by using the first coordinate and the second coordinate;
[0034] The moving module is used to move the second circle so that the coordinates of the center of the second circle after the movement are the third coordinates.
[0035] Optionally, in the embodiment of the present invention, the determining module includes:
[0036] A first determining unit, used to determine two circles selected by the user in the document;
[0037] The second determining unit is used to determine the circle with a larger radius of the two circles as the first circle that keeps the same position, and determine the circle with a smaller radius of the two circles as the second circle to be moved.
[0038] Optionally, in an embodiment of the present invention, the obtaining module includes:
[0039] A first obtaining unit, used to obtain the coordinates of the upper left corner vertex of a first circumscribed rectangle of the first circle and a first radius of the first circle;
[0040] A first calculation unit, used to calculate the first coordinates of the center of the first circle by using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the first radius;
[0041] A second obtaining unit, used to obtain the coordinates of the upper left corner vertex of a second circumscribed rectangle of the second circle and a second radius of the second circle;
[0042] The second calculation unit is used to calculate the second coordinates of the center of the second circle by using the coordinates of the upper left corner vertex of the second circumscribed rectangle and the second radius.
[0043] Optionally, in an embodiment of the present invention, the calculation module includes:
[0044] A third determining unit is used to determine that the angle formed by the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system is 90° or 270° when the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the horizontal coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the vertical coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is greater than zero;
[0045] a fourth determining unit, for calculating an angle between the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system, using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle, when the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is not zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero;
[0046] A third calculation unit is used to calculate the absolute value of the difference between the first radius and the second radius as the center point distance between the center of the first circle and the center of the second circle when the first circle and the second circle are tangent to each other;
[0047] A fourth calculation unit, used to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle by using the distance between the center points of the circles, the angle, the second radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle;
[0048] The fifth calculation unit is used to calculate the third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle by using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
[0049] Optionally, in this embodiment of the present invention, the fifth computing unit is specifically configured to:
[0050] Substitute the center point distance, the included angle, the radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle into a preset calculation formula to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle;
[0051] The preset calculation formulas include:
[0052] X2=d×sinα-r2+x1
[0053] Y2=d×cosα-r2+y1
[0054] Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle.
[0055] 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, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0056] Memory, used to store computer programs;
[0057] The processor is used to implement the method steps of any of the above-mentioned graphics processing methods when executing the program stored in the memory.
[0058] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the method steps of any of the above-mentioned graphics processing methods are implemented.
[0059] In a fifth aspect, an embodiment of the present invention further provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute: any one of the method steps of the above-mentioned graphics processing method.
[0060] In an embodiment of the present invention, the first circle and the second circle selected by the user in the document can be determined. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0061] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the embodiments of the present invention 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 some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0063] Figure 1 A flowchart of a graphics processing method provided by an embodiment of the present invention;
[0064] Figure 2 A schematic diagram of the positional relationship between two circles provided in an embodiment of the present invention;
[0065] Figure 3 Another schematic diagram of the positional relationship between two circles provided in an embodiment of the present invention;
[0066] Figure 4 A schematic diagram of the structure of a graphics processing device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0067] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0068] In order to solve the technical problems existing in the related art, the embodiments of the present invention provide a graphics processing method, device, electronic device and readable storage medium.
[0069] The electronic device may execute the steps of the graphics processing method provided by the embodiment of the present invention. The electronic device includes but is not limited to a computer, a smart phone, and a smart wearable device.
[0070] In addition, the electronic device may be installed with office software, and the user may draw a circle using the drawing tools in the office software, wherein the office software includes but is not limited to: word software, PPT (PowerPoint, presentation) software and WPS (WPS software, WPS software) software.
[0071] See also Figure 1 The graphics processing method provided by the embodiment of the present invention may include the following steps:
[0072] S101: Determine a first circle and a second circle selected by a user in a document;
[0073] For example, when a user is making a courseware, he needs to move two circles drawn in the document so that the outer side of one circle is tangent to the inner side of the other circle, that is, the two circles are tangent to each other. Figure 2 The two circles shown are moved to obtain Figure 3 The two circles shown are tangent to each other. Figure 2 A schematic diagram of the positional relationship between two circles provided in an embodiment of the present invention; Figure 3 Another schematic diagram of the positional relationship between two circles provided in an embodiment of the present invention.
[0074] Among them, when the user selects the following in the document Figure 2 After the two circles are shown, the electronic device can determine the two circles selected by the user. In addition, the circle with a larger radius of the two circles can be determined as the first circle to be kept in the same position, and the circle with a smaller radius of the two circles can be determined as the second circle to be moved. In this way, during the image processing process, the position of the larger first circle can be kept unchanged, and the smaller second circle can be moved to a position tangent to the first circle, thereby improving the graphic movement speed.
[0075] Of course, it is also reasonable to determine the circle with the smaller radius of the two circles as the first circle that keeps the same position, and to determine the circle with the larger radius of the two circles as the second circle to be moved.
[0076] It is understandable that the user can select the first circle and the second circle at the same time by box selection, and of course can also select the first circle and the second circle that meet the radius condition by inputting the radius of the first circle and the second circle, but it is certainly not limited to this.
[0077] The circle in the embodiment of the present invention refers to a perfect circle with a width-to-height ratio of 1:1.
[0078] S102: Obtaining a first coordinate of the center of the first circle and a second coordinate of the center of the second circle;
[0079] Continuing with the above example, when the electronic device Figure 2 After the circle with the larger radius of the two circles is determined as the first circle and the circle with the smaller radius of the two circles is determined as the second circle, the electronic device can obtain the upper left corner vertex coordinates of the first circumscribed rectangle of the first circle and the first radius of the first circle. Then, the first coordinates of the center of the first circle are calculated using the upper left corner vertex coordinates of the first circumscribed rectangle and the first radius.
[0080] Specifically, the electronic device can establish a rectangular coordinate system with the point at the upper left corner of the electronic device screen as the coordinate origin, wherein the direction from the coordinate origin horizontally to the right can be used as the horizontal axis, and the direction from the coordinate origin vertically downward can be used as the vertical axis.
[0081] Thus, the electronic device can obtain the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the first radius r1 of the first circle. Then, the first coordinates (cx1, cy1) of the center of the first circle can be calculated using the coordinates of the upper left corner vertex (x1, y1) and the first radius r1. The first coordinates (cx1, cy1) of the center of the first circle can be calculated using the following formula:
[0082]
[0083] Similarly, the electronic device can also obtain the upper left corner vertex coordinates (x2, y2) of the second circumscribed rectangle of the second circle and the second radius r2 of the second circle. Then, the second coordinates (cx2, cy2) of the center of the second circle can be calculated using the upper left corner vertex coordinates (x2, y2) of the second circumscribed rectangle and the second radius r2. The second coordinates (cx2, cy2) of the center of the second circle can be calculated using the following formula:
[0084]
[0085] In this way, the first coordinates of the center of the first circle can be calculated based on the coordinates of the upper left corner vertex of the first circle and the first radius; and the second coordinates of the center of the second circle can be calculated based on the coordinates of the upper left corner vertex of the second circle and the second radius. In this way, the coordinates of the centers of the two circles before the two circles are moved can be quickly calculated.
[0086] S102: Calculate the third coordinate of the center of the second circle when the first circle is tangent to the second circle using the first coordinate and the second coordinate;
[0087] After obtaining the first coordinates of the center of the first circle and the second coordinates of the center of the second circle, the electronic device may determine to keep the position of the first circle unchanged and move the second circle.
[0088] When the electronic device determines to keep the position of the first circle unchanged and move the second circle, the electronic device can determine whether: the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the horizontal coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the vertical coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is greater than zero.
[0089] If the conditions are met, the electronic device can determine that the angle formed by the straight line where the center of the first circle and the center of the second circle are located and the horizontal axis of the rectangular coordinate system is 90° or 270°.
[0090] If not, the electronic device can use the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the upper left corner vertex coordinates of the second circumscribed rectangle of the second circle to calculate the angle between the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system.
[0091] Specifically, the angle can be calculated by the following formula:
[0092] α=tan -1 (cd y / cd x )
[0093] cd y =y2-y1
[0094] cd x =x2-x1
[0095] Wherein, α is the angle between the straight line where the center of the first circle and the center of the second circle are located and the horizontal axis of the rectangular coordinate system; cd y cd is the difference between the ordinate of the upper left corner vertex of the second circumscribed rectangle and the ordinate of the upper left corner vertex of the first circumscribed rectangle; x is the difference between the horizontal coordinate of the upper left corner vertex of the second circumscribed rectangle and the horizontal coordinate of the upper left corner vertex of the first circumscribed rectangle.
[0096] In addition, the electronic device can also calculate the absolute value of the difference between the first radius and the second radius as the center point distance between the center of the first circle and the center of the second circle when the first circle and the second circle are tangent to each other. Afterwards, the center point distance, the included angle, the second radius of the second circle and the upper left corner vertex coordinates of the first circumscribed rectangle of the first circle can be used to calculate the upper left corner vertex coordinates of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other.
[0097] The center point distance, the included angle, the radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle can be substituted into a preset calculation formula to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle;
[0098] The preset calculation formula includes:
[0099] X2=d×sinα-r2+x1
[0100] Y2=d×cosα-r2+y1
[0101] Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle.
[0102] Afterwards, the electronic device can calculate the third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle by using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
[0103] Specifically, the third coordinate (cX2, cY2) of the center of the second circle can be calculated as follows:
[0104]
[0105] S103: Move the second circle so that the coordinates of the center of the moved second circle are the third coordinates.
[0106] After the third coordinate is calculated, the second circle can be moved to a position where the coordinate of the center of the second circle is the third coordinate, thereby automatically moving the second circle so that the first circle is tangent to the inside of the second circle. Figure 2 After moving the circle shown in Figure 3 The first circle shown is a graphic that is tangent to the inside of the second circle.
[0107] In an embodiment of the present invention, the first circle and the second circle selected by the user in the document can be determined. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0108] Corresponding to the above method embodiment, the present invention also provides a graphics processing device, see Figure 4 , the device may include:
[0109] Determining module 401, for a first circle and a second circle selected by a user in a document;
[0110] An obtaining module 402 is used to obtain a first coordinate of the center of the first circle and a second coordinate of the center of the second circle;
[0111] A calculation module 403, used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the second circle by using the first coordinate and the second coordinate;
[0112] The moving module 404 is used to move the second circle so that the coordinates of the center of the second circle after the movement are the third coordinates.
[0113] By using the device provided by the embodiment of the present invention, the first circle and the second circle selected by the user in the document can be determined. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0114] Optionally, in the embodiment of the present invention, the determining module 401 may include:
[0115] A first determining unit, used to determine two circles selected by the user in the document;
[0116] The second determining unit is used to determine the circle with a larger radius of the two circles as the first circle that keeps the same position, and determine the circle with a smaller radius of the two circles as the second circle to be moved.
[0117] Optionally, in the embodiment of the present invention, the obtaining module 402 may include:
[0118] A first obtaining unit, used to obtain the coordinates of the upper left corner vertex of a first circumscribed rectangle of the first circle and a first radius of the first circle;
[0119] A first calculation unit, used to calculate the first coordinates of the center of the first circle by using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the first radius;
[0120] A second obtaining unit, used to obtain the coordinates of the upper left corner vertex of a second circumscribed rectangle of the second circle and a second radius of the second circle;
[0121] The second calculation unit is used to calculate the second coordinates of the center of the second circle by using the coordinates of the upper left corner vertex of the second circumscribed rectangle and the second radius.
[0122] Optionally, in this embodiment of the present invention, the calculation module 403 may include:
[0123] A third determining unit is used to determine that the angle formed by the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system is 90° or 270° when the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the horizontal coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the vertical coordinates of the upper left corner vertex coordinates of the second circumscribed rectangle is greater than zero;
[0124] a fourth determining unit, for calculating an angle between the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system, using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle, when the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is not zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero;
[0125] A third calculation unit is used to calculate the absolute value of the difference between the first radius and the second radius as the center point distance between the center of the first circle and the center of the second circle when the first circle and the second circle are tangent to each other;
[0126] A fourth calculation unit, used to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle by using the distance between the center points of the circles, the angle, the second radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle;
[0127] The fifth calculation unit is used to calculate the third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle by using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
[0128] Optionally, in the embodiment of the present invention, the fifth computing unit may be specifically configured to:
[0129] Substitute the center point distance, the included angle, the radius of the second circle and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle into a preset calculation formula to calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle;
[0130] The preset calculation formulas include:
[0131] X2=d×sinα-r2+x1
[0132] Y2=d×cosα-r2+y1
[0133] Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate in the coordinates of the upper left corner vertex of the first circumscribed rectangle.
[0134] Corresponding to the above method embodiment, an embodiment of the present invention further provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0135] Memory, used to store computer programs;
[0136] The processor is used to implement the method steps of any of the above-mentioned graphics processing methods when executing the program stored in the memory.
[0137] In an embodiment of the present invention, the first circle and the second circle selected by the user in the document can be determined. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0138] Corresponding to the above method embodiments, an embodiment of the present invention further provides a readable storage medium, in which a computer program is stored. When the computer program is executed by a processor, the method steps of any of the above graphics processing methods are implemented.
[0139] After the computer program stored in the readable storage medium provided by the embodiment of the present invention is executed by the processor of the electronic device, the electronic device can determine the first circle and the second circle selected by the user in the document. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0140] Corresponding to the above method embodiments, an embodiment of the present invention further provides a computer program product, which, when executed on an electronic device, enables the electronic device to execute: the method steps of any of the above graphics processing methods.
[0141] After the computer program product provided by the embodiment of the present invention is executed by the processor of the electronic device, the electronic device can determine the first circle and the second circle selected by the user in the document. In addition, the first coordinate of the center of the first circle and the second coordinate of the center of the second circle can be obtained. Afterwards, the first coordinate and the second coordinate can be used to calculate the third coordinate of the center of the second circle when the first circle is tangent to the inside of the second circle. Then, the second circle can be moved so that the coordinate of the center of the second circle after the move is the third coordinate. In this way, the third coordinate of the center of the second circle when the first circle and the second circle are tangent to the inside can be simply and quickly calculated, so that the second circle can be quickly moved to a position tangent to the inside of the first circle based on the third coordinate.
[0142] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0143] The communication interface is used for communication between the above electronic device and other devices.
[0144] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0145] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0146] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can 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 the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center 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 can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0147] 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 existence of other identical elements in the process, method, article or device including the elements.
[0148] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, readable storage medium and computer program product embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.
[0149] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection 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
1. A method for processing graphics in a document, characterized in that: The method comprises: Determine a first circle and a second circle selected by a user in the document; Obtain a first coordinate of the center of the first circle and a second coordinate of the center of the second circle; Using the first coordinate and the second coordinate, calculate the third coordinate of the center of the second circle when the first circle is tangent to the second circle; Move the second circle so that the coordinates of the center of the second circle after the movement are the third coordinates; The step of determining the first circle and the second circle selected by the user in the document includes: Determine the two circles selected by the user in the document; The circle with the larger radius among the two circles is determined as a first circle to be kept in a fixed position, and the circle with the smaller radius among the two circles is determined as a second circle to be moved; The obtaining of the first coordinate of the center of the first circle and the second coordinate of the center of the second circle comprises: Obtaining the coordinates of the upper left corner vertex of a first circumscribed rectangle of the first circle and a first radius of the first circle; Calculate the first coordinates of the center of the first circle by using the coordinates of the upper left corner vertex of the first circumscribed rectangle and the first radius; Obtain the coordinates of the upper left corner vertex of a second circumscribed rectangle of the second circle and a second radius of the second circle; The second coordinates of the center of the second circle are calculated using the coordinates of the upper left corner vertex of the second circumscribed rectangle and the second radius.
2. The method according to claim 1, characterized in that The step of calculating the third coordinate of the center of the second circle when the first circle is tangent to the second circle by using the first coordinate and the second coordinate includes: When the difference between the abscissa of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the abscissa of the coordinates of the upper left corner vertex of the second circumscribed rectangle is zero, and the difference between the ordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the ordinate of the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero, determining that the angle formed by the straight line where the centers of the first circle and the second circle are located and the abscissa of the rectangular coordinate system is 90° or 270°; When the difference between the abscissa of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the abscissa of the coordinates of the upper left corner vertex of the second circumscribed rectangle is not zero, and the difference between the ordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle and the ordinate of the coordinates of the upper left corner vertex of the second circumscribed rectangle is greater than zero, the angle formed by the straight line where the centers of the first circle and the second circle are located and the abscissa of the rectangular coordinate system is calculated using the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the coordinates of the upper left corner vertex of the second circumscribed rectangle of the second circle; Calculating an absolute value of a difference between the first radius and the second radius as the center point distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; Calculate the coordinates of the upper left corner of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle by using the center point distance, the included angle, the second radius of the second circle and the coordinates of the upper left corner of the first circumscribed rectangle of the first circle; The third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle are calculated using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
3. The method according to claim 2, characterized in that The step of calculating the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle by using the distance between the center points of the circles, the angle, the second radius of the second circle, and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle comprises: Substituting the center point distance, the included angle, the radius of the second circle, and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle into a preset calculation formula, calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle; Wherein, the preset calculation formula includes: X2=d×sinα-r2+x1 Y2=d×cosα-r2+y1 Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle.
4. A device for processing graphics in a document, characterized in that: The device comprises: A determination module, for a first circle and a second circle selected by a user in a document; An obtaining module, used for obtaining a first coordinate of a center point of the first circle and a second coordinate of a center point of the second circle; a calculation module, configured to calculate, by using the first coordinate and the second coordinate, a third coordinate of the center of the second circle when the first circle is tangent to the second circle; A moving module, used for moving the second circle so that the coordinates of the center of the second circle after the movement are the third coordinates; Wherein, the determination module includes: A first determining unit, used to determine two circles selected by the user in the document; A second determining unit is used to determine the circle with a larger radius among the two circles as a first circle to be kept in a fixed position, and to determine the circle with a smaller radius among the two circles as a second circle to be moved; The acquisition module comprises: A first obtaining unit, used to obtain the coordinates of the upper left corner vertex of a first circumscribed rectangle of the first circle and a first radius of the first circle; A first calculation unit, configured to calculate first coordinates of a center of the first circle by using the coordinates of an upper left corner vertex of the first circumscribed rectangle and the first radius; A second obtaining unit, used to obtain the coordinates of the upper left corner vertex of a second circumscribed rectangle of the second circle and a second radius of the second circle; The second calculation unit is used to calculate the second coordinates of the center of the second circle by using the coordinates of the upper left corner vertex of the second circumscribed rectangle and the second radius.
5. The device according to claim 4, characterized in that The calculation module comprises: A third determining unit is used to determine that the angle formed by the straight line where the center of the first circle and the center of the second circle are located and the horizontal axis of the rectangular coordinate system is 90° or 270° when the difference between the horizontal coordinate of the upper left corner vertex coordinate of the first circumscribed rectangle and the horizontal coordinate of the upper left corner vertex coordinate of the second circumscribed rectangle is zero, and the difference between the vertical coordinate of the upper left corner vertex coordinate of the first circumscribed rectangle and the vertical coordinate of the upper left corner vertex coordinate of the second circumscribed rectangle is greater than zero; a fourth determining unit, configured to calculate an angle between the straight line where the centers of the first circle and the second circle are located and the horizontal axis of the rectangular coordinate system, using the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle and the coordinates of the upper left corner vertex of the second circumscribed rectangle of the second circle, when the difference between the horizontal coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the upper left corner vertex coordinates of the second circumscribed rectangle is not zero, and the difference between the vertical coordinates of the upper left corner vertex coordinates of the first circumscribed rectangle and the upper left corner vertex coordinates of the second circumscribed rectangle is greater than zero; a third calculation unit, configured to calculate an absolute value of a difference between the first radius and the second radius as a center point distance between a center point of the first circle and a center point of the second circle when the first circle and the second circle are tangent to each other; a fourth calculation unit, configured to calculate the coordinates of the upper left corner vertex of a third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle by using the center point distance, the included angle, the second radius of the second circle, and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle; The fifth calculation unit is used to calculate the third coordinates of the center of the second circle when the first circle is tangent to the inside of the second circle by using the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle and the second radius.
6. The device according to claim 5, characterized in that The fifth computing unit is specifically configured to: Substituting the center point distance, the included angle, the radius of the second circle, and the coordinates of the upper left corner vertex of the first circumscribed rectangle of the first circle into a preset calculation formula, calculate the coordinates of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle is tangent to the inside of the second circle; Wherein, the preset calculation formula includes: X2=d×sinα-r2+x1 Y2=d×cosα-r2+y1 Among them, X2 is the horizontal coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; Y2 is the vertical coordinate of the upper left corner vertex of the third circumscribed rectangle of the second circle when the first circle and the second circle are tangent to each other; d is the distance between the center points of the first circle and the second circle when the first circle and the second circle are tangent to each other; α is the angle formed by the straight line where the center points of the first circle and the second circle are located and the horizontal axis of the coordinate system when the first circle and the second circle are tangent to each other; r2 is the radius of the second circle; x1 is the horizontal coordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle; y1 is the vertical coordinate of the coordinates of the upper left corner vertex of the first circumscribed rectangle.
Citation Information
Patent Citations
Mobile terminal positioning method and device based on Bluetooth technology
CN103560813A
Method and device for graphic information processing
JP1996096158A
Method and device for graphic processing
JP1996329268A
Method and device for plotting picture by computer, and recording medium recording picture plotting program
JP1998247255A
System and method for dynamic geometry suggestion tool
US20160307470A1
