Disclosure of Invention
The application provides a coordinate axis drawing method and device, which aim to solve the problem that codes for drawing coordinate axes are too huge and redundant in order to deal with coordinate system change in the prior art.
According to the coordinate axis drawing method provided by the embodiment of the application, the method comprises the following steps:
receiving the coordinates of a starting point and an end point of a coordinate axis to be drawn and the distance between scale marks;
drawing a vector pointing from the start point coordinate to the end point coordinate;
calculating the scale point coordinates of each scale mark in the coordinate axis to be drawn on the vector according to the scale mark intervals;
and drawing scale marks perpendicular to the vector according to the scale point coordinates, thereby finishing the drawing of the coordinate axis.
Optionally, according to the distance between the scale marks, calculating a scale point coordinate of each scale mark in the coordinate axis to be drawn on the vector, specifically including:
equally dividing the vector according to the distance between the scale marks;
and calculating the coordinate of each scale point on the averaged vector.
Optionally, according to the coordinate of the scale point, a scale line perpendicular to the vector is drawn, which specifically includes:
acquiring the length of a preset scale line;
and drawing a scale mark which is perpendicular to the vector and has the length of the scale mark by taking the scale mark coordinate as a starting point coordinate.
Optionally, according to the coordinate of the scale point, a scale line perpendicular to the vector is drawn, which specifically includes:
calculating a unit vertical vector according to the vector;
calculating the end point coordinate of the other end corresponding to the scale point coordinate in the scale line to be drawn according to the unit vertical vector and the length of the preset scale line;
and drawing a line segment of which the scale point coordinates are connected with the corresponding endpoint coordinates to obtain a scale line to be drawn and which is perpendicular to the vector.
Optionally, the drawn scale line is perpendicular to the direction of the vector, and is determined by:
acquiring a preset mark value; the marking value is used for indicating the direction of the drawn scale mark perpendicular to the vector;
and determining the direction of the scale mark perpendicular to the vector according to the mark value.
According to the device for drawing the coordinate axis provided by the embodiment of the application, the device comprises:
the receiving unit is used for receiving the coordinates of the starting point and the end point of the coordinate axis to be drawn and the distance between the scale marks;
a vector drawing unit that draws a vector pointing from the start point coordinate to the end point coordinate;
the calculating unit is used for calculating the scale point coordinates of each scale mark in the coordinate axis to be drawn on the vector according to the scale mark intervals;
and the scale mark drawing unit is used for drawing the scale marks vertical to the vector according to the scale point coordinates, so that the drawing of the coordinate axis is completed.
Optionally, the computing unit specifically includes:
the equipartition unit is used for equipartiting the vector according to the scale mark interval;
and the calculating subunit calculates the coordinates of each scale point on the averaged vector.
Optionally, the scale line drawing unit specifically includes:
the acquisition subunit acquires the length of a preset scale line;
and the drawing subunit draws the scale mark which is perpendicular to the vector and has the length of the scale mark by taking the scale mark coordinate as the starting point coordinate.
Optionally, the scale line drawing unit specifically includes:
a first calculation subunit that calculates a unit vertical vector from the vector;
the second calculating subunit calculates the end point coordinate of the other end corresponding to the scale point coordinate in the scale line to be drawn according to the unit vertical vector and the preset scale line length;
and the drawing subunit is used for drawing a line segment of which the scale point coordinates are connected with the corresponding end point coordinates to obtain a scale line to be drawn and which is perpendicular to the vector.
Optionally, the drawn scale line is perpendicular to the direction of the vector, and is determined by the following subunits:
a second obtaining subunit, for obtaining a preset mark value; the marking value is used for indicating the direction of the drawn scale mark perpendicular to the vector;
and the determining subunit determines the direction of the scale mark perpendicular to the vector according to the mark value.
In the embodiment of the application, the coordinate axis is drawn based on the vector, so that the drawn coordinate axis and the coordinate system are unbound, any change of the coordinate system does not need to be considered, corresponding codes do not need to be configured, and the code amount of the drawn coordinate axis is reduced.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application. As used in this application and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It is to be understood that although the terms first, second, third, etc. may be used herein to describe various information, such information should not be limited to these terms. These terms are only used to distinguish one type of information from another. For example, first information may also be referred to as second information, and similarly, second information may also be referred to as first information, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
Fig. 1 is a schematic diagram of coordinate axes provided in the present application. The coordinate axis may generally consist of a coordinate axis 11, a number of graduation marks 12.
The graduation marks 12 are perpendicular to the coordinate axis 11 and divide the coordinate axis 11 into several segments uniformly.
As previously mentioned, the rendering of coordinate axes is generally based on a coordinate system. Since the coordinate system can be varied widely, e.g. transpose, reflect, rotate, translate, zoom, etc.; therefore, each time the coordinate system is changed, the corresponding coordinate axis also needs to be changed.
For example, a schematic diagram of coordinate axes in a coordinate system as shown in fig. 2. The coordinate system is a rectangular coordinate system, and is provided with two coordinate axes which are respectively a right horizontal coordinate axis: + X axis; upward vertical coordinate system: + Y axis. After the coordinate system in fig. 2 is reflected by the Y-axis, the coordinate system is changed to the coordinate axis after reflection as shown in fig. 3. As can be seen from the change from fig. 2 to fig. 3, since the coordinate system is changed, the horizontal coordinate axis originally from the right: + X axis, changed to the horizontal coordinate axis to the left: -an X-axis; the scale lines on the coordinate axes and the images also change correspondingly.
This requires that the coordinate axes be re-coded for each change when the coordinate axes are plotted.
However, the coordinate system varies, the code cannot cover all the conditions, and even if the code covers all the conditions, the code for drawing coordinate axes is too large and redundant, and the maintenance is difficult
In order to solve the above problem, a flowchart of a coordinate axis drawing method according to an embodiment of the present application shown in fig. 4 is described below.
The method and the device can be applied to any equipment provided with the webpage chart drawing engine. The device may be, for example, a desktop computer, a laptop computer, a tablet computer, a smart phone, a handheld computer, a personal digital assistant ("PDA"), or any other wired or wireless processor driven device.
The method may comprise the steps of:
step 210: and receiving the coordinates of the starting point and the end point of the coordinate axis to be drawn and the distance between the scale marks.
In this embodiment, in the process of drawing the coordinate axis, after the user inputs the start point coordinate, the end point coordinate, and the scale line interval of the coordinate axis to be drawn, the device may automatically draw the coordinate axis to be drawn.
Step 220: a vector is drawn from the start point coordinate to the end point coordinate.
In the related art, a vector (also referred to as a vector) may refer to a directional line segment having a magnitude and a direction.
In the vector diagram shown in fig. 5, the arrow point B is the end of the vector, and the arrow tail point a is the beginning of the vector, i.e. the vector AB, points from the point a to the point B and is marked as
The size of a vector is the length of the vector, i.e. the modulus of the vector, noted
In this embodiment, after receiving the coordinates of the start point and the end point of the coordinate axis to be drawn, the device may draw a vector pointing from the coordinate of the start point to the coordinate of the end point according to the coordinates of the start point and the end point.
For example, assume the start point coordinates are (x0, y0) and the end point coordinates are (x1, y 1);
from these two points, the corresponding vector pointing from the starting point a to the end point B can be calculated:
step 230: and calculating the scale point coordinates of each scale mark in the coordinate axis to be drawn on the vector according to the scale mark intervals.
As previously mentioned, the coordinate axis has graduation marks perpendicular to the coordinate axis and evenly divides the coordinate axis into several segments.
Therefore, the graduation line spacing can represent the length of each section of the coordinate axis after the division.
In this embodiment, after the vector pointing from the start coordinate to the end coordinate is drawn and the inter-scale distance of the coordinate axis to be drawn is received, the device may calculate the coordinate of the scale point of each scale line in the coordinate axis to be drawn on the vector according to the inter-scale distance.
Specifically, the step 130 may include:
a1: equally dividing the vector according to the distance between the scale marks;
a2: and calculating the coordinate of each scale point on the averaged vector.
The example in the previous step is carried forward, namely the vector is drawn with the coordinates of the starting point being (x0, y0) and the coordinates of the ending point being (x1, y1)
As shown in fig. 6, assume that the tick mark spacing is value.
According to the scale mark interval, the scales can be equally divided
The scale points on this vector can be derived as shown in fig. 7: b0, B1, B2, B3, B4, B5, B6.
Specifically, the coordinates of each scale point are calculated as follows:
calculate scale point B0 coordinate:
B0:(x0+rangeX*value,y0+rangeY*value);
wherein x0 and y0 are coordinates of the starting point A; range x is given by the following equation 1, and range y is given by the following equation 2:
var ranging x-x 1-x0 formula 1
var ranging y1-y0 equation 2
On the basis of the calculated coordinates of the scale point B0, assuming that the coordinates of the scale point B0 are (x2, y2), the coordinates of the scale point B1 are calculated:
B1:(x2+rangeX*value,y2+rangeY*value);
on the basis of the calculated coordinates of the scale point B1, assuming that the coordinates of the scale point B1 are (x3, y3), the coordinates of the scale point B2 are calculated:
B2:(x3+rangeX*value,y3+rangeY*value);
on the basis of the calculated coordinates of the scale point B2, assuming that the coordinates of the scale point B2 are (x4, y4), the coordinates of the scale point B3 are calculated:
B3:(x4+rangeX*value,y4+rangeY*value)。
after the coordinates of the scale point B2 are calculated to be (x5, y5), the coordinates of all scale points, i.e., B0(x2, y2), B2(x3, y3), B2(x4, y4), and B3(x5, y5), are obtained.
Step 240: and drawing scale marks perpendicular to the vector according to the scale point coordinates, thereby finishing the drawing of the coordinate axis.
As previously mentioned, the graduation marks are perpendicular to the coordinate axis. Therefore, after the coordinates of the scale points of each scale line on the vector are obtained through calculation, the scale lines perpendicular to the vector can be drawn according to the coordinates of the scale points, and accordingly the drawing of the coordinate axis is completed.
In this embodiment, the step 240 may specifically include:
acquiring the length of a preset scale line;
and drawing a scale mark which is perpendicular to the vector and has the length of the scale mark by taking the scale mark coordinate as a starting point coordinate.
In this embodiment, the length of the calibration line may be an empirical value preset by a human. Or may be input by the user before drawing the coordinate axes.
After the device obtains the preset length of the scale line, for each scale line coordinate, the scale line coordinate can be used as a starting point coordinate to draw the scale line which is perpendicular to the vector and has the length of the scale line length. As shown in fig. 8, the coordinate axis diagram is a schematic drawing of a coordinate axis, a drawn vector is a coordinate axis of the coordinate axis, and a drawn scale line is perpendicular to the vector.
In this embodiment, the step 240 may specifically include
Calculating a unit vertical vector according to the vector;
calculating the end point coordinate of the other end corresponding to the scale point coordinate in the scale line to be drawn according to the unit vertical vector and the length of the preset scale line;
and connecting the scale point coordinates with the corresponding end point coordinates to obtain the scale mark to be drawn, which is perpendicular to the vector.
In this embodiment, when the scale lines are drawn, after the scale point on the vector of each scale line is calculated, the end point coordinate of the other end corresponding to the scale point needs to be calculated.
Since the scale mark is perpendicular to the vector, when the scale mark is drawn, the vector can be converted into a unit vector, and the unit perpendicular vector of the vector can be calculated according to vector multiplication; and multiplying the unit vertical vector by the length of the preset scale line to obtain a vector from the scale point to the end point of the other end, wherein the vector is assumed to be an offset vector. With the vector and the coordinates of either end of the vector known, the coordinates of the other end of the vector can be obtained.
In this embodiment, taking the scale point B0 as an example, the coordinate of the end point C0 at the other end of the scale point B0 shown in fig. 9 is:
C0:(B0.x+offsetVector.x,B0.y+offsetVector.y);
wherein b0.x represents the abscissa of the scale point B0, i.e., x 2; x denotes the abscissa of the vector offsetVector;
b0.y represents the ordinate of the scale point B0, i.e. y 2; offset vector.y represents the ordinate of the vector offset vector.
In a similar manner, the first and second substrates are,
end point coordinate C1 of the other end of scale point B1: (b1.x + offset vector. x, b1.y + offset vector. y);
end point coordinate C1 of the other end of scale point B2: (b2.x + offset vector. x, b2.y + offset vector. y);
end point coordinate C1 of the other end of scale point B3: (b2.x + offset vector. x, b2.y + offset vector. y).
After calculating the end point coordinates corresponding to all the scale points, each pair of scale point coordinates and the corresponding end point coordinates can be connected to obtain the scale mark to be drawn, which is perpendicular to the vector.
According to the method and the device, the coordinate axis is drawn based on the vector, so that the drawn coordinate axis and the coordinate system are unbound, any change of the coordinate system does not need to be considered, corresponding codes do not need to be configured, and the code amount of the drawn coordinate axis is reduced.
In the above embodiment, the scale lines drawn perpendicular to the direction of the vector are determined by:
acquiring a preset mark value; the marking value is used for indicating the direction of the drawn scale mark perpendicular to the vector
And determining the direction of the scale mark perpendicular to the vector according to the mark value.
The marker value is used to indicate the direction in which the drawn tick mark is perpendicular to the vector.
In practice, the tick marks are perpendicular to the vector, and as shown, it is not certain whether the tick marks are above or below the vector. Of course, a default value may be set. For example by default, to be positioned below the vector.
In the present embodiment, a mark value for indicating a direction in which a drawn scale line is perpendicular to a vector is proposed. The marker value may be entered by a user prior to drawing the coordinate axis.
The direction of the graduation mark perpendicular to the vector can be controlled by the marking value. For example, the value 1 indicates upward, the value 2 indicates downward, and after the device acquires the preset mark value, the device can determine the direction of the graduation mark perpendicular to the vector according to the mark value.
In the prior art, the drawing of the coordinate axes depends on the position, such as the canvas schematic diagram shown in fig. 10, and the user can only draw the coordinate axes at the positions of top, bottom, left, and right of the canvas. However, for the drawing of the parallel coordinate system shown in fig. 11, since a plurality of parallel coordinate axes need to be drawn in a horizontal position, the position-based drawing method in the related art cannot draw the plurality of parallel coordinate axes at the same time.
The coordinate axis drawing method provided by the embodiment of the application does not need to depend on positions, so that the requirement of drawing a plurality of parallel coordinate axes can be met.
In the prior art, because the coordinate axes are drawn depending on the position, the coordinate axes can only be drawn at the positions of top, bottom, left, and right of the canvas, and therefore the tilted coordinate axes cannot be drawn.
In the coordinate axis drawing method provided in the embodiment of the present application, since there is no need to rely on a position or a coordinate system, as in the examples provided in the embodiments shown in fig. 6 to 9, after the user inputs the start point coordinate, the end point coordinate, and the distance between the scale lines, the drawing of an oblique coordinate axis can be completed at one time.
Corresponding to the embodiment of the coordinate axis drawing method, the application also provides an embodiment of a coordinate axis drawing device. The embodiment of the apparatus may be implemented by software, or by hardware, or by a combination of hardware and software. The software implementation is taken as an example, and is formed by reading corresponding computer program instructions in the nonvolatile memory into the memory for operation through the processor of the device where the software implementation is located as a logical means. In terms of hardware, as shown in fig. 12, the hardware structure diagram of the device where the drawing apparatus of the present application coordinate axis is located is shown, except for the processor, the network interface, the memory, and the nonvolatile memory shown in fig. 12, the device where the apparatus is located in the embodiment may generally include other hardware according to the actual drawing function of the coordinate axis, which is not described again.
Referring to fig. 13, a block diagram of an apparatus for plotting coordinate axes provided in an embodiment of the present application includes: a receiving unit 310, a vector drawing unit 320, a calculating unit 330, and a scale line drawing unit 340.
The receiving unit 310 receives coordinates of a starting point and an end point of a coordinate axis to be drawn and a scale line interval;
a vector drawing unit 320 that draws a vector pointing from the start point coordinate to the end point coordinate;
the calculating unit 330 is configured to calculate a scale point coordinate of each scale line in the coordinate axis to be drawn on the vector according to the scale line interval;
and the scale mark drawing unit 340 draws the scale marks perpendicular to the vector according to the scale point coordinates, thereby completing the drawing of the coordinate axis.
In an alternative implementation:
the calculating unit 330 specifically includes:
the equipartition unit is used for equipartiting the vector according to the scale mark interval;
and the calculating subunit calculates the coordinates of each scale point on the averaged vector.
In an alternative implementation:
the scale line drawing unit 340 specifically includes:
the acquisition subunit acquires the length of a preset scale line;
and the drawing subunit draws the scale mark which is perpendicular to the vector and has the length of the scale mark by taking the scale mark coordinate as the starting point coordinate.
In an alternative implementation:
the scale line drawing unit 340 specifically includes:
a first calculation subunit that calculates a unit vertical vector from the vector;
the second calculating subunit calculates the end point coordinate of the other end corresponding to the scale point coordinate in the scale line to be drawn according to the unit vertical vector and the preset scale line length;
and the drawing subunit is used for drawing a line segment of which the scale point coordinates are connected with the corresponding end point coordinates to obtain a scale line to be drawn and which is perpendicular to the vector.
In an alternative implementation:
the drawn scale lines are perpendicular to the direction of the vector, and are determined by the following subunits:
a second obtaining subunit, for obtaining a preset mark value; the marking value is used for indicating the direction of the drawn scale mark perpendicular to the vector;
and the determining subunit determines the direction of the scale mark perpendicular to the vector according to the mark value.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. A typical implementation device is a computer, which may take the form of a personal computer, laptop computer, cellular telephone, camera phone, smart phone, personal digital assistant, media player, navigation device, email messaging device, game console, tablet computer, wearable device, or a combination of any of these devices.
The implementation process of the functions and actions of each unit in the above device is specifically described in the implementation process of the corresponding step in the above method, and is not described herein again.
For the device embodiments, since they substantially correspond to the method embodiments, reference may be made to the partial description of the method embodiments for relevant points. The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the application. One of ordinary skill in the art can understand and implement it without inventive effort.
In summary, in the embodiment of the present application, the training platform enables at least two customer service staff to solve the problem that the customer service robot cannot solve together through a training mode, automatically determines the answer of the corresponding problem according to the fed back multiple pieces of solution information, and sends the answer and the problem to the customer service robot system after being associated. Therefore, a plurality of experts are not needed to deal with the problem which cannot be solved by the customer service robot, and extra cost is not generated due to the fact that the training personnel answer, so that the overall answer cost is reduced. On the other hand, since the problems are the latest problems and generally reflect the current hot spot problems, the answers of the problems are returned to the customer service robot system, so that the knowledge base of the customer service robot system is perfected, and the success rate of answering the questions is improved. On the other hand, for the training platform, problems which cannot be solved by the customer service robot can be used for setting questions, the problem that the question bank is slow to update is solved, and the problems sent by the customer service robot system are all problems closely related to real users, so that the service processing capacity of customer service personnel can be effectively improved, and the training effect is improved.
Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the invention following, in general, the principles of the application and including such departures from the present disclosure as come within known or customary practice within the art to which the invention pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the application being indicated by the following claims.
It will be understood that the present application is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.