CN107895381A - Distance determines method and device - Google Patents

Distance determines method and device Download PDF

Info

Publication number
CN107895381A
CN107895381A CN201711230178.5A CN201711230178A CN107895381A CN 107895381 A CN107895381 A CN 107895381A CN 201711230178 A CN201711230178 A CN 201711230178A CN 107895381 A CN107895381 A CN 107895381A
Authority
CN
China
Prior art keywords
angle
angled triangle
value
target
targets
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.)
Granted
Application number
CN201711230178.5A
Other languages
Chinese (zh)
Other versions
CN107895381B (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.)
Hangzhou Electronic Soul Network Technology Co Ltd
Original Assignee
Hangzhou Electronic Soul Network Technology 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 Hangzhou Electronic Soul Network Technology Co Ltd filed Critical Hangzhou Electronic Soul Network Technology Co Ltd
Priority to CN201711230178.5A priority Critical patent/CN107895381B/en
Publication of CN107895381A publication Critical patent/CN107895381A/en
Application granted granted Critical
Publication of CN107895381B publication Critical patent/CN107895381B/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
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request

Abstract

The present invention provides a kind of distance and determines method and device, is related to field of computer technology.Two targets on scene map and scene map of this programme based on the net region being arranged in array along X-axis and Y-axis, build the first right angled triangle and the second right angled triangle, and using the distance of end points of the hypotenuse of the second right angled triangle away from first object and the second target as the first length of side value, using the length of side value sum of the first length of side value and the hypotenuse of the second right angled triangle as first object and the second target the distance between be worth, to improve the precision for determining distance, the consumption to computing resource is reduced simultaneously, helps to lift the fluency of game picture.

Description

Distance determines method and device
Technical field
The present invention relates to field of computer technology, and method and device is determined in particular to a kind of distance.
Background technology
With the fast development of computer technology, the requirement more and more higher to data operation.For example, in electronic game row Industry, usually, the ultimate range that game role moves every time are fixed, it is therefore desirable to judge whether game role completes this It is mobile, that is, total displacement of the game role in this moving process is calculated, total displacement is usually one section Path or the sum in multistage path.At present, calculate per segment distance when, generally using the path two-end-point transverse and longitudinal coordinate it Difference, and the distance in path is obtained according to Pythagorean theorem, the calculating process needs to be related to out radical sign, computing resource is consumed high. Although in the prior art, can calculating the distance of two-end-point by Manhattan algorithm, that is, the difference by the transverse and longitudinal coordinate of two-end-point And the distance as two-end-point, although this method can reduce computing resource, easily cause the distance and actual range of calculating Deviation it is larger.
The content of the invention
In order to overcome above-mentioned deficiency of the prior art, the present invention provides a kind of distance and determines method and device, reducing While the consumption of calculation resources, can also ensure the distance of calculating has higher precision, and then solves the above problems.
To achieve these goals, the technical scheme that present pre-ferred embodiments are provided is as follows:
Present pre-ferred embodiments provide a kind of distance and determine method, applied to electronic equipment, the electronic equipment storage There is scene map, this method includes:
Obtain two targets on the scene map includes along X-axis in X-axis and the coordinate data of Y-axis, the scene map And the net region that Y-axis is arranged in array, each net region are associated with corresponding coordinate data;
Judge whether abscissa and/or the ordinate of two targets are identical;
When the abscissa and different ordinate of two targets, according to the coordinate data and of two targets One default construction strategy builds the first right angled triangle, makes the extension side of two right-angle sides of first right angled triangle of structure To identical with the bearing of trend of the X-axis, Y-axis respectively, the summit of the acute angle of the first right angled triangle two is respectively two institutes State position corresponding to target, and using larger one of two acute angles as the first interior angle, the mesh of the vertex correspondence of first interior angle It is denoted as first object, using another target as the second target;
According to second of right-angle side structure preset angle angle value corresponding to the summit of first interior angle and first interior angle Right angled triangle, a summit of second right angled triangle is identical with summit corresponding to first interior angle, and described second The right angle of right angled triangle is identical with the right angle of first right angled triangle;
By end points of the hypotenuse of the second right angled triangle away from the first object and the distance of second target As the first length of side value, using first length of side value and the length of side value sum of the hypotenuse of second right angled triangle as described in First object and the second target the distance between value.
Alternatively, above-mentioned preset angle angle value β is less than or equal to angle value in described first, for first right angled triangle, Using the right-angle side adjacent with first interior angle as the first right-angle side, the right-angle side relative with first interior angle is as second Right-angle side, the length of side value a of first right-angle side and the length of side value b of the second right-angle side can be sat by the transverse and longitudinal of two targets The difference of mark is calculated;
First length of side value m and second right angled triangle hypotenuse value n sums are the first object and second The distance between target, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.
Alternatively, if first interior angle is less than 60 °, the predetermined angle is 45 °, the first object and the second target The distance between value S be
Alternatively, if first interior angle is more than or equal to 60 °, the predetermined angle is 60 °, the first object and second Target the distance between value S be
Alternatively, above-mentioned coordinate data and first default the first right angle three of construction strategy structure according to two targets Angular step, including:
Using position corresponding to the abscissa of the first object and the ordinate of second target as prebuild The right-angled apices of one right angled triangle, built with coordinate data corresponding to the right-angled apices, the first object and the second target First right angled triangle.
Alternatively, above-mentioned coordinate data and first default the first right angle three of construction strategy structure according to two targets Angular step, including:
Using position corresponding to the ordinate of the first object and the abscissa of second target as prebuild The right-angled apices of one right angled triangle, built with coordinate data corresponding to the right-angled apices, the first object and the second target First right angled triangle.
Alternatively, when the abscissa of two targets is identical, when ordinate is different, methods described also includes:
Distance using the difference of the ordinate of two targets as two targets.
Alternatively, when the ordinate of two targets is identical, during abscissa difference, methods described also includes:
Distance using the difference of the abscissa of two targets as two targets.
Presently preferred embodiments of the present invention also provides one kind apart from determining device, applied to electronic equipment, the electronic equipment Scene map is stored with, it is described to include apart from determining device:
Coordinate acquiring unit, it is described for obtaining on the scene map two targets in X-axis and the coordinate data of Y-axis Scene map includes the net region being arranged in array along X-axis and Y-axis, and each net region is associated with corresponding number of coordinates According to;
Whether coordinate judging unit, the abscissa and/or ordinate for judging two targets are identical;
First construction unit;For when the abscissa and different ordinate of two targets, according to two The coordinate data of target and the first default construction strategy build the first right angled triangle, make first right angled triangle of structure Two right-angle sides bearing of trend it is identical with the bearing of trend of the X-axis, Y-axis respectively, the acute angle of the first right angled triangle two Summit be respectively position corresponding to two targets, and using larger one of two acute angles as the first interior angle, described first The target of the vertex correspondence of interior angle is as first object, using another target as the second target;
Second construction unit, built for right-angle side corresponding to the summit according to first interior angle and first interior angle Second right angled triangle of preset angle angle value, a summit of second right angled triangle summit corresponding with first interior angle It is identical, and the right angle of second right angled triangle is identical with the right angle of first right angled triangle;
Distance determining unit, for by end points of the hypotenuse of the second right angled triangle away from the first object and institute The distance of the second target is stated as the first length of side value, by first length of side value and the side of the hypotenuse of second right angled triangle Long value sum as the first object and the second target the distance between value.
Alternatively, above-mentioned preset angle angle value β is less than or equal to angle value in described first, for first right angled triangle, Using the right-angle side adjacent with first interior angle as the first right-angle side, the right-angle side relative with first interior angle is as second Right-angle side, the length of side value a of first right-angle side and the length of side value b of the second right-angle side can be sat by the transverse and longitudinal of two targets The difference of mark is calculated;
First length of side value m and second right angled triangle hypotenuse value n sums are the first object and second The distance between target, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.
In terms of existing technologies, distance provided by the invention determines that method and device at least has below beneficial to effect Fruit:On scene map and scene map of the scheme provided by the invention based on the net region being arranged in array along X-axis and Y-axis Two targets, the first right angled triangle and the second right angled triangle are built, and by the hypotenuse of the second right angled triangle away from first The distance of the end points of target and the second target is as the first length of side value, by the hypotenuse of the first length of side value and the second right angled triangle Length of side value sum as first object and the second target the distance between value, to improve the precision for determining distance, reduce simultaneously Consumption to computing resource, help to lift the fluency of game picture.
To enable the above objects, features and advantages of the present invention to become apparent, present pre-ferred embodiments cited below particularly, And accompanying drawing appended by coordinating, it is described in detail below.
Brief description of the drawings
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below by embodiment it is required use it is attached Figure is briefly described.It should be appreciated that the following drawings illustrate only certain embodiments of the present invention, therefore it is not construed as pair The restriction of scope, for those of ordinary skill in the art, on the premise of not paying creative work, can also be according to this A little accompanying drawings obtain other related accompanying drawings.
Fig. 1 is the block diagram for the electronic equipment that present pre-ferred embodiments provide.
Fig. 2 is the schematic flow sheet that the distance that present pre-ferred embodiments provide determines method.
Fig. 3 is the schematic diagram of the triangle for the structure that present pre-ferred embodiments provide.
Fig. 4 is to use Manhattan algorithm to use error pair of the predetermined angle for 45 ° of algorithm with the present invention in the prior art Compare schematic diagram.
Fig. 5 is the block diagram apart from determining device that present pre-ferred embodiments provide.
Icon:10- electronic equipments;11- processing units;12- communication units;13- memory cell;100- distances determine to fill Put;110- coordinate acquiring units;120- coordinate judging units;The construction units of 130- first;The construction units of 140- second;150- away from From determining unit.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation describes.Obviously, described embodiment is only the part of the embodiment of the present invention, rather than whole embodiments.It is logical The component for the embodiment of the present invention being often described and illustrated herein in the accompanying drawings can be configured to arrange and design with a variety of.
Therefore, below the detailed description of the embodiments of the invention to providing in the accompanying drawings be not intended to limit it is claimed The scope of the present invention, but be merely representative of the present invention selected embodiment.Based on embodiments of the invention, people in the art The every other embodiment that member is obtained on the premise of creative work is not made, belongs to the scope of protection of the invention.
It should be noted that:Similar label and letter represents similar terms in following accompanying drawing, therefore, once a certain Xiang Yi It is defined, then it further need not be defined and explained in subsequent accompanying drawing in individual accompanying drawing.In addition, term " the One ", " second " etc. is only used for distinguishing description, and it is not intended that instruction or hint relative importance.
In the prior art, such as in map determine two targets apart from when, generally use Manhattan algorithm, Be exactly difference and as two targets the distance using the difference of the abscissa of two targets and ordinate, but which cause to determine away from It is larger from actual range error.Although the calculation of Pythagorean theorem can be used to determine the distance of this two target, it is related to Radical sign computing is opened, and in game process, the number of the distance of two targets of calculating is more, causes the computing resource consumption to system Greatly.Understandably, the computing resource can be the part percentage for being used to calculate distance in the processor of electronic equipment.
How a kind of distance of science is provided and determines method, the consumption to computing resource can be reduced, while can also improve The precision of the distance of determination, it is a great problem of those skilled in the art.In view of the above problems, present inventor is by long-term Research and probe, following examples are proposed to solve the above problems.Below in conjunction with the accompanying drawings, the embodiment of the present invention is elaborated. In the case where not conflicting, the feature in following embodiment and embodiment can be mutually combined.
Fig. 1 is refer to, the block diagram of the electronic equipment 10 provided for present pre-ferred embodiments.The electronic equipment 10 It may be, but not limited to, smart mobile phone, PC (personal computer, PC), tablet personal computer, personal digital assistant (personal digital assistant, PDA), mobile internet surfing equipment (mobile Internet device, MID) etc..
In the present embodiment, the electronic equipment 10 can include processing unit 11, communication unit 12, memory cell 13 with And apart from determining device 100, the processing unit 11, communication unit 12, memory cell 13 and each apart from determining device 100 Directly or indirectly it is electrically connected between element, to realize the transmission of data or interaction.For example, these elements can lead between each other Cross one or more communication bus or signal wire is realized and is electrically connected with.
The processing unit 11 can be processor.For example, the processor can be central processing unit (Central Processing Unit, CPU), network processing unit (Network Processor, NP), graphics processor (Graphics Processing Unit, GPU) etc.;It can also be that digital signal processor (DSP), application specific integrated circuit (ASIC), scene can Program gate array (FPGA) either other PLDs, discrete gate or transistor logic, discrete hardware components. It can realize or perform disclosed each method, step and the logic diagram in the embodiment of the present invention.
The communication unit 12 is used for the communication connection by network and server, and passes through the network transceiving data. The server can be the game server for game services.
The memory cell 13 may be, but not limited to, random access memory, read-only storage, may be programmed read-only deposit Reservoir, Erasable Programmable Read Only Memory EPROM, Electrically Erasable Read Only Memory etc..In the present embodiment, the storage Unit 13 can be used for storage scenarios map.Certainly, the memory can be also used for storage program, and the processing unit 11 exists After receiving execute instruction, the program is performed.
Further, it is described apart from determining device 100 include it is at least one can be with the shape of software or firmware (firmware) Formula is stored in the memory cell 13 or is solidificated in the operating system of electronic equipment 10 (operating system, OS) Software function module.The processing unit 11 is used to performing the executable module that is stored in the memory cell 13, such as away from From the software function module included by determining device 100 and computer program etc..
It is understood that the structure shown in Fig. 1 is only a kind of structural representation of electronic equipment 10, the electronic equipment 10 can also include than more or less components shown in Fig. 1.For example the electronic equipment 10 can be used as single-play game equipment, It is not provided with communication unit 12.Each component shown in Fig. 1 can use hardware, software or its combination to realize.
Fig. 2 is refer to, the distance provided for present pre-ferred embodiments determines the schematic flow sheet of method.The distance determines Method can be applied to above-mentioned electronic equipment 10, and this is performed apart from determination method by the electronic equipment 10.Wherein, the electronic equipment 10 are previously stored with scene map, and the scene map can be the scene map of game.
It will determine that each step of method is described in detail to the distance shown in Fig. 2 below, in the present embodiment, should be away from It may comprise steps of from determination method:
Step S210, obtain two targets on scene map includes in X-axis and the coordinate data of Y-axis, the scene map The net region being arranged in array along X-axis and Y-axis, each net region are associated with corresponding coordinate data.
Understandably, the scene map is divided in multiple net region (not shown) being arranged in array, it is preferable that The net region is rectangular area, and the length bearing of trend of each horizontally-arranged net region is identical with X-axis bearing of trend, each vertical The length bearing of trend for arranging net region is identical with the bearing of trend of Y-axis.In addition, each net region is associated with corresponding horizontal seat Mark data and ordinate data.Wherein, horizontally-arranged and file is orthogonal position relationship, that is, horizontally-arranged and file is relative Position relationship, and it is not necessarily referring to absolute transverse and longitudinal position relationship.
Step S220, judge whether the abscissa of two targets and/or ordinate are identical.
Understandably, it is determined that two targets apart from when, the position of two targets is likely located at same horizontally-arranged net region On, or on the net region of same file.For example if the ordinate of two targets is identical, two targets are just positioned at same On horizontally-arranged net region;If the abscissa of two targets is identical, two targets are just on the net region of same file.It is and right In the abscissa and/or ordinate identical situation of two targets, right angled triangle can need not be built to calculate two targets Distance.
Step S230, when the abscissa and different ordinate of two targets, according to the seat of two targets Mark data and the first default construction strategy builds the first right angled triangle, make two right angles of first right angled triangle of structure The bearing of trend on side is identical with the bearing of trend of the X-axis, Y-axis respectively, the summit point of the acute angle of the first right angled triangle two Not Wei position corresponding to two targets, and using larger one of two acute angles as the first interior angle, the top of first interior angle Target is as first object corresponding to point, using another target as the second target.
Alternatively, step S230 can be:By the abscissa of the first object and the ordinate pair of second target Right-angled apices of the position answered as the first right angled triangle of prebuild, with the right-angled apices, the first object and second Coordinate data corresponding to target builds first right angled triangle.Understandably, the described first default construction strategy characterizes:Will First right angle trigonometry of the position as prebuild corresponding to the abscissa of the first object and the ordinate of second target The right-angled apices of shape are straight with coordinate data structure described first corresponding to the right-angled apices, the first object and the second target Angle triangle.
Alternatively, step S230 can also be:By the ordinate of the first object and the abscissa of second target Right-angled apices of the corresponding position as the first right angled triangle of prebuild, with the right-angled apices, the first object and Coordinate data corresponding to two targets builds first right angled triangle.Understandably, the described first default construction strategy also may be used To characterize:Using position corresponding to the ordinate of the first object and the abscissa of second target as the first of prebuild The right-angled apices of right angled triangle, institute is built with coordinate data corresponding to the right-angled apices, the first object and the second target State the first right angled triangle.
Step S240, predetermined angle is built according to right-angle side corresponding to the summit of first interior angle and first interior angle Second right angled triangle of value, a summit of second right angled triangle is identical with summit corresponding to first interior angle, and The right angle of second right angled triangle is identical with the right angle of first right angled triangle.
Preferably, the preset angle angle value is less than or equal to angle value in described first so that the second right angled triangle of structure A wherein right-angle side overlapped with the right-angle side of the first right angled triangle, another right-angle side of the second right angled triangle is located at first On another right-angle side of right angled triangle, and without departing from another right-angle side of the first right angled triangle.
Step S250, by end points of the hypotenuse of the second right angled triangle away from the first object and second mesh Target distance is used as the first length of side value, by first length of side value and the length of side value sum of the hypotenuse of second right angled triangle As the first object and the second target the distance between value.
Fig. 3 is refer to, the schematic diagram of the triangle of the structure provided for present pre-ferred embodiments.In the present embodiment, Assuming that first object is A, the second target is B, and C points are just the first right angled triangle obtained according to the first default construction strategy The summit of (△ ABC), the second right angled triangle are △ DBC, the second right-angle side AC=b, side AD=m, the first right-angle side BC=, the The hypotenuse BD=n of two right angled triangles, predetermined angle ∠ DBC value are β, and the first interior angle is ∠ ABC.
Alternatively, preset angle angle value β is less than or equal to angle value (∠ ABC) in described first, for first right angle trigonometry Shape, using the right-angle side adjacent with first interior angle as the first right-angle side (BC), the right-angle side relative with first interior angle As the second right-angle side (AC), the length of side value a of first right-angle side and the length of side value b of the second right-angle side can be by described in two The difference of the transverse and longitudinal coordinate of target is calculated.End points of the hypotenuse (DB) of second right angled triangle away from the first object (D) distance with second target (A) is as the first length of side value (AD).First length of side value m and second right angle three Angular hypotenuse value n sums be the first object and the second target the distance between, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.Namely using while AD with while DB sums as First object A to the second target B distance, compared to it is existing using while AC and while BC sums as first object A to the second mesh B distance is marked, this programme can improve the precision of the distance of determination, to reduce the error that algorithm is brought.
Alternatively, if first interior angle is less than 60 °, the predetermined angle is 45 °, the first object and the second target The distance between value S beAnd the distance value can carry out approximate calculation, that is, S=b+ with floating-point operation 0.414, to reduce the consumption to computing resource.
Fig. 4 is refer to, to use Manhattan algorithm to use predetermined angle with the present invention as 45 ° of algorithm in the prior art Error contrast schematic diagram.Understandably, the difference of two target lateral coordinates can be as the length of side value b of above-mentioned first right-angle side, two targets The difference of ordinate can be as the length of side value a of the second above-mentioned right-angle side, and the distance that square root algorithm obtains can be used as actual range, Exactly pass through formulaIt is calculated.Algorithm when inventor by this programme by using preset angle as 45 ° The error of the distance of two targets respectively obtained with Manhattan algorithm is contrasted, and can obtain, in the abscissa of two targets and vertical When coordinate is different, the error of the distance obtained using this programme is smaller, and much smaller than the distance obtained using Manhattan algorithm Error.
Alternatively, if first interior angle is more than or equal to 60 °, the predetermined angle is 60 °, the first object and second Target the distance between value S beAnd the distance value can carry out approximate calculation with floating-point operation, that is, S=b+0.268a, to reduce the consumption to computing resource.
Alternatively, when the abscissa of two targets is identical, when ordinate is different, methods described also includes:By two Distance of the difference of the ordinate of the individual target as two targets.
Alternatively, when the ordinate of two targets is identical, during abscissa difference, methods described also includes:By two Distance of the difference of the abscissa of the target as two targets.
Fig. 5 is refer to, the block diagram apart from determining device 100 provided for present pre-ferred embodiments.The present invention One kind of offer is apart from determining device 100, and applied to electronic equipment 10, electronic equipment 10 is stored with scene map, the distance Determining device 100 can be used for performing this apart from determination method, to improve the precision of the distance determined and reduce to computing resource Consumption, contribute to lifted game picture flow degree or in running game, can reduce to the performance of electronic equipment 10 It is required that.This can include coordinate acquiring unit 110, coordinate judging unit 120, the first construction unit apart from determining device 100 130th, the second construction unit 140 and distance determining unit 150.
Coordinate acquiring unit 110, for obtaining on the scene map two targets in X-axis and the coordinate data of Y-axis, institute The net region that scene map includes being arranged in array along X-axis and Y-axis is stated, each net region is associated with corresponding coordinate Data.Specifically, coordinate acquiring unit 110 can be used for performing the step S210 shown in Fig. 2, and the operation content specifically performed can With reference to the detailed description to step S210.
Whether coordinate judging unit 120, the abscissa and/or ordinate for judging two targets are identical.Specifically Ground, coordinate judging unit 120 can be used for performing the step S220 shown in Fig. 2, and the operation content specifically performed can refer to step Rapid S220 detailed description.
First construction unit 130;For when the abscissa and different ordinate of two targets, according to two institutes The coordinate data and the first default construction strategy for stating target build the first right angled triangle, make first right angle trigonometry of structure The bearing of trend of two right-angle sides of shape is identical with the bearing of trend of the X-axis, Y-axis respectively, and first right angled triangle two is sharp The summit at angle is respectively position corresponding to two targets, and using larger one of two acute angles as the first interior angle, described The target of the vertex correspondence of one interior angle is as first object, using another target as the second target.Specifically, the first construction unit 130 can be used for performing the step S230 shown in Fig. 2, and the operation content specifically performed can refer to retouching in detail to step S230 State.
Second construction unit 140, for right-angle side corresponding to the summit according to first interior angle and first interior angle The second right angled triangle of preset angle angle value is built, a summit of second right angled triangle is corresponding with first interior angle Summit is identical, and the right angle of second right angled triangle is identical with the right angle of first right angled triangle.Specifically, second Construction unit 140 can be used for performing the step S240 shown in Fig. 2, and the operation content specifically performed can refer to step S240's It is described in detail.
Distance determining unit 150, for by the end points of the hypotenuse of the second right angled triangle away from the first object Distance with second target is as the first length of side value, by first length of side value and the hypotenuse of second right angled triangle Length of side value sum as the first object and the second target the distance between value.Specifically, distance determining unit 150 can For performing the step S250 shown in Fig. 2, the operation content specifically performed can refer to the detailed description to step S250.
Alternatively, the preset angle angle value β is less than or equal to angle value in described first, for first right angled triangle, Using the right-angle side adjacent with first interior angle as the first right-angle side, the right-angle side relative with first interior angle is as second Right-angle side, the length of side value a of first right-angle side and the length of side value b of the second right-angle side can be sat by the transverse and longitudinal of two targets The difference of mark is calculated;First length of side value m and second right angled triangle hypotenuse value n sums are the first object With the second target the distance between, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.
Through the above description of the embodiments, those skilled in the art can be understood that the present invention can lead to Hardware realization is crossed, the mode of necessary general hardware platform can also be added by software to realize, based on such understanding, this hair Bright technical scheme can be embodied in the form of software product, and the software product can be stored in a non-volatile memories In medium (can be CD-ROM, USB flash disk, mobile hard disk etc.), including some instructions are causing a computer equipment (can be Personal computer, server, or network equipment etc.) perform method described in each implement scene of the present invention.
In summary, the present invention provides a kind of distance and determines method and device.Based on what is be arranged in array along X-axis and Y-axis Two targets on the scene map and scene map of net region, the first right angled triangle and the second right angled triangle are built, And using the distance of end points of the hypotenuse of the second right angled triangle away from first object and the second target as the first length of side value, by The length of side value sum of the hypotenuse of one side long value and the second right angled triangle as first object and the second target the distance between Value, to improve the precision for determining distance, while the consumption to computing resource is reduced, help to lift the fluency of game picture.
The preferred embodiments of the present invention are the foregoing is only, are not intended to limit the invention, for the skill of this area For art personnel, the present invention can have various modifications and variations.Within the spirit and principles of the invention, that is made any repaiies Change, equivalent substitution, improvement etc., should be included in the scope of the protection.

Claims (10)

1. a kind of distance determines method, it is characterised in that applied to electronic equipment, the electronic equipment is stored with scene map, This method includes:
Obtain two targets on the scene map includes along X-axis and Y-axis in X-axis and the coordinate data of Y-axis, the scene map The net region being arranged in array, each net region are associated with corresponding coordinate data;
Judge whether abscissa and/or the ordinate of two targets are identical;
It is pre- according to the coordinate data of two targets and first when the abscissa and different ordinate of two targets If construction strategy builds the first right angled triangle, make the bearing of trend point of two right-angle sides of first right angled triangle of structure Not identical with the bearing of trend of the X-axis, Y-axis, the summit of the acute angle of the first right angled triangle two is respectively two mesh Position corresponding to mark, and make larger one of two acute angles as the first interior angle, the target of the vertex correspondence of first interior angle For first object, using another target as the second target;
According to the second right angle of right-angle side structure preset angle angle value corresponding to the summit of first interior angle and first interior angle Triangle, a summit of second right angled triangle is identical with summit corresponding to first interior angle, and second right angle The right angle of triangle is identical with the right angle of first right angled triangle;
Using the distance of end points of the hypotenuse of the second right angled triangle away from the first object and second target as First length of side value, using first length of side value and the length of side value sum of the hypotenuse of second right angled triangle as described first Target and the second target the distance between value.
2. according to the method for claim 1, it is characterised in that the preset angle angle value β is less than or equal to first interior angle Value, for first right angled triangle, using the right-angle side adjacent with first interior angle as the first right-angle side, with described the The relative right-angle side of one interior angle is as the second right-angle side, the length of side value a of first right-angle side and the length of side value b of the second right-angle side It can be calculated by the difference of the transverse and longitudinal coordinate of two targets;
First length of side value m and second right angled triangle hypotenuse value n sums are the first object and the second target The distance between, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.
3. according to the method for claim 2, it is characterised in that if first interior angle is less than 60 °, the predetermined angle is 45 °, the first object and the second target the distance between value S be
4. according to the method for claim 2, it is characterised in that if first interior angle is more than or equal to 60 °, the preset angle Spend for 60 °, the first object and the second target the distance between value S be
5. according to the method for claim 1, it is characterised in that the coordinate data and first according to two targets The step of default construction strategy builds the first right angled triangle, including:
Using position corresponding to the abscissa of the first object and the ordinate of second target as the first straight of prebuild The right-angled apices of angle triangle, with described in coordinate data structure corresponding to the right-angled apices, the first object and the second target First right angled triangle.
6. according to the method described in any one in claim 1-5, it is characterised in that the seat according to two targets The step of marking data and first default the first right angled triangle of construction strategy structure, including:
Using position corresponding to the ordinate of the first object and the abscissa of second target as the first straight of prebuild The right-angled apices of angle triangle, with described in coordinate data structure corresponding to the right-angled apices, the first object and the second target First right angled triangle.
7. according to the method described in any one in claim 1-5, it is characterised in that when the abscissa phase of two targets Together, when ordinate is different, methods described also includes:
Distance using the difference of the ordinate of two targets as two targets.
8. according to the method described in any one in claim 1-5, it is characterised in that when the ordinate phase of two targets Together, during abscissa difference, methods described also includes:
Distance using the difference of the abscissa of two targets as two targets.
9. one kind is apart from determining device, it is characterised in that applied to electronic equipment, the electronic equipment is stored with scene map, It is described to include apart from determining device:
Coordinate acquiring unit, for obtaining on the scene map two targets in X-axis and the coordinate data of Y-axis, the scene Map includes the net region being arranged in array along X-axis and Y-axis, and each net region is associated with corresponding coordinate data;
Whether coordinate judging unit, the abscissa and/or ordinate for judging two targets are identical;
First construction unit;For when the abscissa and different ordinate of two targets, according to two targets Coordinate data and the first default construction strategy build the first right angled triangle, make the two of first right angled triangle of structure The bearing of trend of right-angle side is identical with the bearing of trend of the X-axis, Y-axis respectively, the top of the acute angle of the first right angled triangle two Point is respectively position corresponding to two targets, and using larger one of two acute angles as the first interior angle, first interior angle Vertex correspondence target as first object, using another target as the second target;
Second construction unit, it is default for right-angle side structure corresponding to the summit according to first interior angle and first interior angle Second right angled triangle of angle value, a summit of second right angled triangle summit phase corresponding with first interior angle Together, and the right angle of second right angled triangle is identical with the right angle of first right angled triangle;
Distance determining unit, for by end points of the hypotenuse of the second right angled triangle away from the first object and described the The distance of two targets is as the first length of side value, by first length of side value and the length of side value of the hypotenuse of second right angled triangle Sum as the first object and the second target the distance between value.
It is 10. according to claim 9 apart from determining device, it is characterised in that the preset angle angle value β is less than or equal to described Angle value in first, for first right angled triangle, using the right-angle side adjacent with first interior angle as the first right-angle side, The right-angle side relative with first interior angle is as the second right-angle side, the length of side value a and the second right-angle side of first right-angle side Length of side value b can be calculated by the difference of the transverse and longitudinal coordinate of two targets;
First length of side value m and second right angled triangle hypotenuse value n sums are the first object and the second target The distance between, according to formula:
S=m+n=b-atan β+asec β
Calculate the first object and the second target the distance between value S.
CN201711230178.5A 2017-11-29 2017-11-29 Distance determination method and device Active CN107895381B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711230178.5A CN107895381B (en) 2017-11-29 2017-11-29 Distance determination method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711230178.5A CN107895381B (en) 2017-11-29 2017-11-29 Distance determination method and device

Publications (2)

Publication Number Publication Date
CN107895381A true CN107895381A (en) 2018-04-10
CN107895381B CN107895381B (en) 2020-06-12

Family

ID=61806727

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711230178.5A Active CN107895381B (en) 2017-11-29 2017-11-29 Distance determination method and device

Country Status (1)

Country Link
CN (1) CN107895381B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115982542A (en) * 2023-03-21 2023-04-18 湖北泰跃卫星技术发展股份有限公司 Method and device for calculating adjacent relation between lands and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR20090093918A (en) * 2009-08-05 2009-09-02 이현성 Using the secod law of cosine the Wireless Mobile-station position's estimation method
JP4714827B2 (en) * 2008-07-25 2011-06-29 本田技研工業株式会社 Vehicle driving support device
CN102914287A (en) * 2012-10-16 2013-02-06 廖云开 Earth-sun distance measuring method
CN103839241A (en) * 2014-03-21 2014-06-04 北京航空航天大学 Interpolation triangle forming method and device
CN105981074A (en) * 2014-11-04 2016-09-28 深圳市大疆创新科技有限公司 Camera calibration
CN106872944A (en) * 2017-02-27 2017-06-20 海尔优家智能科技(北京)有限公司 A kind of sound localization method and device based on microphone array

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP4714827B2 (en) * 2008-07-25 2011-06-29 本田技研工業株式会社 Vehicle driving support device
KR20090093918A (en) * 2009-08-05 2009-09-02 이현성 Using the secod law of cosine the Wireless Mobile-station position's estimation method
CN102914287A (en) * 2012-10-16 2013-02-06 廖云开 Earth-sun distance measuring method
CN103839241A (en) * 2014-03-21 2014-06-04 北京航空航天大学 Interpolation triangle forming method and device
CN105981074A (en) * 2014-11-04 2016-09-28 深圳市大疆创新科技有限公司 Camera calibration
CN106872944A (en) * 2017-02-27 2017-06-20 海尔优家智能科技(北京)有限公司 A kind of sound localization method and device based on microphone array

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115982542A (en) * 2023-03-21 2023-04-18 湖北泰跃卫星技术发展股份有限公司 Method and device for calculating adjacent relation between lands and storage medium
CN115982542B (en) * 2023-03-21 2023-08-29 湖北泰跃卫星技术发展股份有限公司 Method, device and storage medium for calculating adjacent relation between lands

Also Published As

Publication number Publication date
CN107895381B (en) 2020-06-12

Similar Documents

Publication Publication Date Title
CN108154548A (en) Image rendering method and device
CN113010937B (en) Parametric modeling method of member section steel bar and related device
US20080117208A1 (en) Method for constructing a triangular mesh surface of a point cloud
CN108159693B (en) Game scene construction method and device
US10019802B2 (en) Graphics processing unit
CN111135561A (en) Game role display method, device, storage medium and electronic equipment
CN113077548B (en) Collision detection method, device, equipment and storage medium for object
US20160266775A1 (en) Interface providing systems and methods for enabling efficient screen control
WO2021164251A1 (en) Image annotation task pre-verification method and apparatus, device, and storage medium
CN111127612A (en) Game scene node updating method and device, storage medium and electronic equipment
CN112632141A (en) Visualization method and device for blood margin analysis data, computer equipment and medium
CN107895381A (en) Distance determines method and device
CN113515792B (en) Intelligent checking method and device for graph model
CN111773685A (en) Method and device for dynamically generating game role visual field
CN108053751B (en) Method and device for drawing direction arrow on electronic map navigation route
CN108171794B (en) Plane view projection method, device, equipment and medium based on three-dimensional model
CN108564637B (en) Geometric model arrangement method and device
US11887255B2 (en) Method and system for rendering boundary of map area within game map, and computer-readable storage medium
CN107704708B (en) Linear engineering section coordinate calculation method, device and equipment
CN108305329B (en) Model building method and terminal
CN107369194B (en) Method and device for filling pattern
CN113160422B (en) Positioning method for exhibit position, computing equipment and readable storage medium
CN111768464B (en) Graph adjustment method and device
CN112199760B (en) Structure size labeling method and device, terminal equipment and storage medium
CN110727755A (en) Polygon squaring method, electronic equipment 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
EE01 Entry into force of recordation of patent licensing contract
EE01 Entry into force of recordation of patent licensing contract

Application publication date: 20180410

Assignee: Hangzhou spoon Network Technology Co., Ltd

Assignor: Hangzhou dianhun Network Technology Co., Ltd

Contract record no.: X2021330000727

Denomination of invention: Distance determination method and device

Granted publication date: 20200612

License type: Common License

Record date: 20211109