CN100517346C - Path-finding method for optimal path - Google Patents

Path-finding method for optimal path Download PDF

Info

Publication number
CN100517346C
CN100517346C CNB2006100003132A CN200610000313A CN100517346C CN 100517346 C CN100517346 C CN 100517346C CN B2006100003132 A CNB2006100003132 A CN B2006100003132A CN 200610000313 A CN200610000313 A CN 200610000313A CN 100517346 C CN100517346 C CN 100517346C
Authority
CN
China
Prior art keywords
point
path
shortest path
starting point
straight line
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CNB2006100003132A
Other languages
Chinese (zh)
Other versions
CN1996320A (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.)
Shenzhen Tencent Computer Systems Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CNB2006100003132A priority Critical patent/CN100517346C/en
Publication of CN1996320A publication Critical patent/CN1996320A/en
Application granted granted Critical
Publication of CN100517346C publication Critical patent/CN100517346C/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention provides a optimal path searching method. It creates typological chart made of spot and lines of the scenic spot, computing the initial shortest path of the designated two points in the typological chart, with the initial shortest path being formed by serial passed spots and lines, sequentially judging the direct linear arrival from the start point of the initial shortest path to the continuous spots, till the farthest spot away from the start point, and judging whether the farthest spot is the final point or not, if not, regarding the farthest point as the start point and return to execute this step, otherwise, sequentially connecting two points between them as the optimal path output. It provides a smooth treatment for the shortest path, substituting the zigzag path by the line reachable path, representing the shortest path optimization, improving the activeness of the user.

Description

A kind of path-finding method of optimal path
Technical field
The present invention relates to the method for calculating path, relate in particular to the path-finding method of the optimal path between any 2 in a kind of two dimension or the 3D grid.
Background technology
In the two and three dimensions recreation of computing machine, many scenes are arranged, for example, corridor in house, the house, the earth, ocean etc., be described for the form of these scene computing machines with grid, promptly scene is made up of several adjacent grids, generally adopts triangle as basic grid.In two dimension or three dimensions, as long as providing the coordinate on three summits, any one triangle just can decide, especially in 3d gaming, computer system can be come saving scenario by the three-dimensional coordinate of preserving an Atria summit.So, how complicated scene no matter, all the triangular mesh that is not waited by several shapes is formed.What triangular mesh are a scene be divided into, and are to be determined by the landform of this scene and the distribution situation of barrier.
In various scenes, an object will move to another place from a place, often has mulitpath, and this just needs to calculate and to select which paths is shortest path, just optimal path.In scene, any one point can regard as and be arranged in certain triangular mesh of forming scene, just can be equal to the triangular mesh that calculates the some place shortest path to the triangular mesh at another place so calculate shortest path from a point to another point.Each triangular mesh all has the label of oneself, and shortest path can be represented with the label of a series of triangular mesh of order process.In addition, in having the scene of barrier, object moves to another place from a place can not pass barrier, just need the cut-through thing to advance, so triangular mesh for the object place, three limits of triangular mesh can be divided into boundary edge and non-boundary edge, boundary edge is and one of the triangular mesh that is used to represent barrier adjacent limit that object cannot pass boundary edge and advance; Non-boundary edge is and one of the triangular mesh that is used to represent non-barrier adjacent limit that object can pass non-boundary edge and advance.
At present, the common method of the shortest path between any 2 is as follows in the calculating three-dimensional scenic:
At first, set up the topological diagram of scene;
The method of topological diagram of setting up scene is a lot, the mid point on one side that for example will form all triangular mesh of scene links to each other with straight line each other, calculate the air line distance of any two continuous mid points, give certain weight to the air line distance between any two mid points simultaneously, weights are represented to move to the required cost of paying of another point from a bit, for example go up a slope than descending difficulty, the required cost of paying is greater than the required cost of paying of descending, so the weights of the air line distance that expression is gone up a slope are just big so go up a slope.Set up after the topological diagram of scene, because any one point in the scene is all regarded as on certain triangular mesh that is arranged in scene, further, any one point in the scene all can be regarded as on the mid point on the one side that is positioned at triangular mesh, so, seek any shortest path in the scene at 2 and just be converted at topological diagram the short distance problem between 2 that answer of getting it right of falling into a trap.
Next, calculate 2 bee-line of appointment in the topological diagram;
Bee-line calculate at any 2 in such one topological diagram that has weights between has ripe algorithm, for example A star algorithm, Di Jiesitela (Dijkstra) algorithm and Freud (F1oyd) algorithm etc. at present.Because these algorithms are algorithms of comparative maturity, repeat no more here.
At last, the bee-line of obtaining point-to-point transmission by above-mentioned algorithm is the mid point of a series of triangular mesh of order process, so, represent the shortest path of point-to-point transmission with the middle piont mark of the triangular mesh of point-to-point transmission order process, export this shortest path and just solved the shortest route problem of in scene, seeking the point-to-point transmission of appointment.
Yet, there is following shortcoming in the shortest path that adopts above method to calculate: because whole scene is made up of the triangular mesh that several shapes differ, even can not arrive by straight line so there is barrier to stop between 2, so, the shortest path that calculates by above-mentioned existing method still needs the mid point of order through several triangular mesh, so shortest path can present sinuate zigzag, therefore, in the two dimension or 3d gaming of computing machine, when the player makes an object when any moves to another, even having barrier to stop, the centre can not arrive by straight line, the shortest path walked of object also is a cranky circuit so, do not embody the optimality of shortest path like this, make player's experience bad yet, influence user's use enthusiasm.
Summary of the invention
In view of this, the object of the present invention is to provide a kind of path-finding method of optimal path, use method provided by the invention, can replace cranky path, embody the optimality of shortest path with the path that straight line can reach.
In order to realize the foregoing invention purpose, the invention provides a kind of path-finding method of optimal path, this method comprises:
A, set up the topological diagram of being made up of Points And lines of scene, calculate the initial shortest path between 2 of appointment in the topological diagram, this initial shortest path is made up of the Points And lines of order process;
B, judge whether the starting point on the initial shortest path can arrive by straight line to follow-up point successively, until find can with the starting point straight line arrive from starting point point farthest, and judge whether described solstics is terminal point, if not, described solstics as starting point, is returned and carried out this step; Otherwise, execution in step C; Can straight line arrival be meant between 2 do not have barrier to stop;
C, all dot sequency ground straight lines that can straight line between 2 of appointment arrive is continuous and export as optimal path.
Set up scene in the topological diagram of forming by Points And lines of scene described in the steps A and be the grid in computer two-dimensional or the 3d gaming.
When described scene was grid in computer two-dimensional or the 3d gaming, the topological diagram of being made up of Points And lines of setting up scene described in the steps A comprised:
The center of gravity of all grids as the point in the topological diagram, is linked to each other the center of gravity straight line of adjacent mesh as the line in the topological diagram, calculate the air line distance between two adjacent centers of gravity, and give air line distance between two continuous centers of gravity with certain weight.
Initial shortest path in the topological diagram of calculating described in the steps A between 2 of appointment can comprise:
According to the weights of the air line distance in the topological diagram with the air line distance of being given, the initial shortest path in employing A star algorithm, Di Jiesitela dijkstra's algorithm or the Freud Floyd algorithm computation topological diagram between 2 of appointment.
Judge described in the step B whether starting point can reach and can comprise by straight line to follow-up point:
B1, create vector from starting point to follow-up point, and with this DUAL PROBLEMS OF VECTOR MAPPING to the grid plan at starting point place, one side of the grid at the line segment after the mapping and starting point place is crossing;
Whether the limit of the line segment intersection after B2, judgement and the mapping still represents the limit of barrier grid simultaneously, if then starting point cannot arrive by straight line with this follow-up point; Otherwise, the vector of establishment from intersection point to this follow-up point, and with this DUAL PROBLEMS OF VECTOR MAPPING to the grid plan at intersection point place, intersect on one side of the grid at line segment after the mapping and intersection point place, return and carry out this step, drop on until intersection point on the grid of described follow-up point, then starting point and described follow-up point can arrive by straight line.
The above grid can be triangular mesh.
Can see from the above, the path-finding method of optimal path provided by the present invention has following beneficial effect: carry out smoothing by the initial shortest path that prior art is calculated and handle, replace cranky path with the path that straight line can reach, both embodied the optimality of shortest path, can not allow game user that the bad experience of advancing tortuously is arranged again, improve user's use enthusiasm.
Description of drawings
Fig. 1 is a process flow diagram of seeking optimal path according to the present invention;
Fig. 2 is a process flow diagram of doing visual test according to the present invention between 2 o'clock.
Embodiment
In order to make advantages and features of the invention clearer, the present invention is further detailed explanation in conjunction with exemplary embodiment with reference to the accompanying drawings.
Path-finding method with the optimal path between 2 in the scene of Computerized three-dimensional recreation is an example, and the present invention is described in detail.The initial shortest path that obtains according to the method for prior art does not embody the optimality of shortest path fully, even because be that straight line can reach between 2, it is cranky that shortest path remains, to this, the present invention proposes a kind of improving one's methods, and the initial shortest path that prior art is calculated is done smoothing processing, promptly cranky path is replaced in the path that can reach with straight line, concrete treatment scheme is referring to Fig. 1, and Fig. 1 is a process flow diagram of seeking optimal path according to the present invention, and operation steps is as follows:
Step 101, set up the topological diagram of scene, adopt the method for existing calculating shortest path to calculate the initial shortest path of fixed 2 of scene middle finger, and with initial the shortest path center of gravity of the triangular mesh of process and the run trace that the line between the center of gravity is represented initial shortest path in proper order;
In the present embodiment, adopt following method to set up the topological diagram of scene.As mentioned above, any one point in the scene can be regarded certain triangular mesh that is arranged in the composition scene as, because it is very little as the triangular mesh of basic grid, so can think further that any one point can be positioned on the center of gravity of triangular mesh, and with the label of triangular mesh center of gravity label as triangular mesh, so at first find the center of gravity of all triangular mesh of forming scene, the center of gravity of the triangular mesh that all are adjacent links to each other with straight line, and calculate air line distance between all centers of gravity that link to each other, give these air line distances simultaneously with certain weight, thus, just set up the scene topological diagram of forming by Points And lines that has weights.Next, in the topological diagram of such three-dimensional scenic, according to the algorithm of prior art, Di Jiesitela dijkstra's algorithm for example calculates the initial bee-line between 2 of appointment.For example, the initial shortest path that calculating finishes from starting point A to terminal point H, wherein A and H are the center of gravity labels of three-dimensional system of coordinate intermediate cam shape grid, and suppose that the initial shortest path that calculates begins to have passed through in proper order the center of gravity B of triangular mesh from the center of gravity A of triangular mesh, C, D, E, F, G arrives the center of gravity H of triangular mesh, in topological diagram, the center of gravity of these triangular mesh sequentially straight line links to each other, so initial shortest path can be expressed as: A → B → C → D → E → F → G → H, wherein B to G also all be initial shortest path the center of gravity label of each triangular mesh of process.
Owing to adopt above-mentioned method not embody the optimality of shortest path, so continuing that above-mentioned initial shortest path is done smoothing, the present invention handles, promptly do visual test to follow-up point successively from the off, the point farthest that finds starting point can straight line to arrive below is that 2 steps that whether can straight line arrive are promptly judged in visual test.
Step 102, judge whether starting point second after the starting point be visual, if, execution in step 104; Otherwise, execution in step 103;
Shortest path explanation A → B that prior art is calculated must arrive by straight line, otherwise just do not have A to the path of B, so the present invention is as long as consider whether A is all visual just passable to the later each point of C, D and even D, if it is all visual, illustrate that optimal path can pass through the point of each middle center of gravity circuitously, and directly reach home.So, judge at first whether second C of starting point A after the starting point be visual.
Step 103, the more preceding straight line of starting point with second linked to each other, the each point in the middle of getting rid of on shortest path, and more preceding as starting point with second return execution in step 102;
Step 104, judge whether is terminal point at second after the starting point, if, execution in step 106; Otherwise, execution in step 105;
Second after step 105, the starting point is not terminal point, and more following to second point with after second o'clock returns execution in step 102 so;
Second after step 106, the starting point is terminal point, then starting point is linked to each other with second straight line after the starting point, and the label of exporting the shortest path that all straight lines link to each other is as optimal path.
Briefly, visual test tests just whether straight line can reach between 2, if 2 straight lines can reach, then illustrating between 2 does not have barrier, can directly link to each other, and just object can directly arrive, and need not detour; If straight line is unreachable between 2, illustrating between 2 has barrier, and object cannot pass barrier and directly arrive, and needs the cut-through thing.For example, with shortest path A → B → C → D → E → F → G → H is the step of the above-mentioned visual test of example explanation, begin to do visual test from starting point A to a C, A is visual to C, then continue to do the visuality test of A to D, A is not visible to D, then A is linked to each other with preceding 1 C straight line of D, expression can be directly to C from A, needn't pass through B,, begin successively to follow-up D from C then so on shortest path, get rid of B, E, F, G, H does visual test, and visual test draws C to D, C is to E, C is to F, C is visual to G, C is not visible to H, so C is linked to each other with the G straight line, gets rid of D on shortest path, E, F, because putting H has been terminal point, so can stop all visuality tests, G directly be linked to each other with H, at this moment, there is A → C in the path that directly links to each other with straight line, C → G, G → H, thus the shortest path of handling through smoothing just optimal path be: A → C → G → H.
More than described by between 2 o'clock, doing the operating process that visual test comes the initial shortest path that the smoothing processing prior art calculates.The method of visual test of the present invention is described referring to Fig. 2.
Fig. 2 is a process flow diagram of doing visual test according to the present invention between 2 o'clock.Particularly, the test of the visuality from starting point A to terminal point B can be adopted following method:
Step 201, the vector of establishment from starting point A to terminal point B;
Step 202, with this DUAL PROBLEMS OF VECTOR MAPPING to the plane of the triangular mesh at starting point A place, so on the triangular mesh at A place, the line segment after this DUAL PROBLEMS OF VECTOR MAPPING will inevitably intersect with a limit of the triangular mesh at A place;
The attribute on one side that the line segment after step 203, the judgement mapping and the triangular mesh at A place intersect, if boundary edge illustrates A at first adjacent with barrier on the direction of B, A is unreachable to the B straight line, the two is not visible, withdraws from current treatment scheme; Otherwise, execution in step 204;
One side that the line segment after step 204, the mapping and the triangular mesh at A place intersect is non-boundary edge, illustrate that then A is at first adjacent with barrier on the direction of B, so, whether the intersection point that intersect on one side of the line segment after the judgement mapping and the triangular mesh at A place is positioned on the triangular mesh at terminal point B place, if, illustrate that then A and B are visual, withdraw from current treatment scheme; Otherwise, execution in step 205;
The intersection point that intersect on a limit of the triangular mesh at step 205, the line segment after will shining upon and A place returns execution in step 201 as starting point A.
Adopt above-mentioned visual method of testing, can do visual test, judging whether straight line can reach two points, thereby realize the initial shortest path that prior art is calculated is done smoothing processing any two points on the initial shortest path.
More than to be example with the path-finding method of Computerized three-dimensional recreation intermediate cam shape grid have been described in detail the path-finding method of optimal path provided by the invention, yet, method provided by the present invention is not limited to the triangular mesh in the 3d gaming, stands good for other field method provided by the invention.
The above is preferred embodiment of the present invention only, is not to be used to limit protection scope of the present invention.

Claims (5)

1, a kind of path-finding method of optimal path is characterized in that, this method comprises:
A, set up the topological diagram of being made up of Points And lines of scene, calculate the initial shortest path between 2 of appointment in the topological diagram, this initial shortest path is made up of the Points And lines of order process; Described scene is the grid in computer two-dimensional or the 3d gaming;
B, judge whether the starting point on the initial shortest path can arrive by straight line to follow-up point successively, until find can with the starting point straight line arrive from starting point point farthest, and judge whether described solstics is terminal point, if not, described solstics as starting point, is returned and carried out this step; Otherwise, execution in step C; Can straight line arrival be meant between 2 do not have barrier to stop;
C, all dot sequency ground straight lines that can straight line between 2 of appointment arrive is continuous and export as optimal path.
2, method according to claim 1 is characterized in that, the topological diagram of being made up of Points And lines of setting up scene described in the steps A comprises:
The center of gravity of all grids as the point in the topological diagram, is linked to each other the center of gravity straight line of adjacent mesh as the line in the topological diagram, calculate the air line distance between two adjacent centers of gravity, and give air line distance between two continuous centers of gravity with certain weight.
3, method according to claim 2 is characterized in that, the initial shortest path in the topological diagram of calculating described in the steps A between 2 of appointment comprises:
According to the weights of the air line distance in the topological diagram with the air line distance of being given, the initial shortest path in employing A star algorithm, Di Jiesitela dijkstra's algorithm or the Freud Floyd algorithm computation topological diagram between 2 of appointment.
4, method according to claim 1 is characterized in that, judges described in the step B that starting point whether can straight line can reach to follow-up point to comprise:
B1, create vector from starting point to follow-up point, and with this DUAL PROBLEMS OF VECTOR MAPPING to the grid plan at starting point place, one side of the grid at the line segment after the mapping and starting point place is crossing;
Whether the limit of the line segment intersection after B2, judgement and the mapping still represents the limit of barrier grid simultaneously, if then starting point cannot arrive by straight line with this follow-up point; Otherwise, the vector of establishment from intersection point to this follow-up point, and with this DUAL PROBLEMS OF VECTOR MAPPING to the grid plan at intersection point place, intersect on one side of the grid at line segment after the mapping and intersection point place, return and carry out this step, drop on until intersection point on the grid of described follow-up point, then starting point and described follow-up point can arrive by straight line.
5, according to any described method in the claim 1 to 4, it is characterized in that described grid is a triangular mesh.
CNB2006100003132A 2006-01-04 2006-01-04 Path-finding method for optimal path Active CN100517346C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2006100003132A CN100517346C (en) 2006-01-04 2006-01-04 Path-finding method for optimal path

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2006100003132A CN100517346C (en) 2006-01-04 2006-01-04 Path-finding method for optimal path

Publications (2)

Publication Number Publication Date
CN1996320A CN1996320A (en) 2007-07-11
CN100517346C true CN100517346C (en) 2009-07-22

Family

ID=38251408

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2006100003132A Active CN100517346C (en) 2006-01-04 2006-01-04 Path-finding method for optimal path

Country Status (1)

Country Link
CN (1) CN100517346C (en)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101494590B (en) * 2008-01-23 2011-09-21 中兴通讯股份有限公司 Optimum path selection method of communication network based on load balance
CN101504776B (en) * 2009-03-17 2011-03-23 北京像素软件科技股份有限公司 3D scene path finding method and apparatus
CN101848229B (en) * 2009-03-24 2014-06-25 北京理工大学 Method for solving minimum generated network problem in distributed network computing
CN102800242B (en) * 2011-05-25 2014-09-17 腾讯科技(深圳)有限公司 Path finding verification method and device
KR101616291B1 (en) * 2011-10-11 2016-04-29 엠파이어 테크놀로지 디벨롭먼트 엘엘씨 Gathering path data from a massively multiplayer on-line role-playing game
CN102799781B (en) * 2012-07-16 2015-10-28 福建天晴数码有限公司 The optimization method of width object mobile route is had in virtual scene
CN103020443A (en) * 2012-12-08 2013-04-03 大连创达技术交易市场有限公司 Method for map training
CN103021258A (en) * 2012-12-08 2013-04-03 大连创达技术交易市场有限公司 Speed-optimized map way-finding algorithm
CN104613976B (en) * 2014-08-26 2017-12-15 腾讯科技(深圳)有限公司 Determine the method and device in path
CN104462805B (en) * 2014-12-02 2017-05-31 厦门飞游信息科技有限公司 A kind of map road-seeking method based on A* algorithms, equipment and computing terminal
CN104548597B (en) * 2014-12-26 2018-06-01 北京像素软件科技股份有限公司 The automatic generation method and device of navigation grid
CN105574169B (en) * 2015-12-18 2019-08-20 河南思维自动化设备股份有限公司 The storage method of road bureau's line topological figure
CN106202744B (en) * 2016-07-12 2019-09-13 中国能源建设集团广东省电力设计研究院有限公司 Wind power collection system of offshore wind power plant avoidance method for optimizing route and system
CN107194501A (en) * 2017-05-04 2017-09-22 湖州三基色信息科技有限公司 Method based on mess generation path
CN107450535B (en) * 2017-07-31 2018-06-29 中南大学 A kind of intelligence carrying robot optimal path combination chart discusses controlling planning method
CN107598673B (en) * 2017-08-11 2019-07-05 太原科技大学 The method determined based on the plane blank dimension benchmark of shortest path
CN108815850B (en) * 2018-06-15 2021-01-05 腾讯科技(深圳)有限公司 Method and client for controlling path finding of analog object
CN110909961B (en) * 2019-12-19 2023-07-25 盈嘉互联(北京)科技有限公司 BIM-based indoor path query method and device
CN113778106A (en) * 2021-09-26 2021-12-10 上汽通用五菱汽车股份有限公司 Wheeled robot energy-saving track planning method, planning equipment and readable storage medium

Also Published As

Publication number Publication date
CN1996320A (en) 2007-07-11

Similar Documents

Publication Publication Date Title
CN100517346C (en) Path-finding method for optimal path
CN106949893B (en) A kind of the Indoor Robot air navigation aid and system of three-dimensional avoidance
CN105652838B (en) A kind of multi-robots Path Planning Method based on time window
WO2017162036A1 (en) Yawing recognition method, terminal and storage medium
CN107773164B (en) Cleaning method and device for cleaning robot and robot
CN107913039B (en) Block selection method and device for cleaning robot and robot
CN104156459B (en) A kind of method and system of the efficient pathfinding based on identical expense grid
CN103017757B (en) Engineering machinery entering path planning method and path planning apparatus
CN106094834A (en) Based on the method for planning path for mobile robot under known environment
CN107198883A (en) Method for searching and device for game object in virtual game
CN105222774B (en) A kind of indoor orientation method and user terminal
CN104613976B (en) Determine the method and device in path
CN105674995A (en) Method for acquiring commuting route based on user's travel locus, and apparatus thereof
CN104548597B (en) The automatic generation method and device of navigation grid
CN106774395A (en) Agricultural plant protection unmanned plane avoidance sprays paths planning method and unmanned plane
CN108960504A (en) A kind of visualization LK algorithm determines method
CN109409662B (en) Measuring method for correlation between urban traffic and commercial space based on space syntax
CN108168557A (en) Air navigation aid, device, mobile terminal and server
CN107289925A (en) A kind of method and apparatus for drawing user trajectory
CN108268039A (en) The paths planning method and system of mobile robot
CN108733803A (en) A kind of Multi-User Dimension keyword query method under road network
CN110544157A (en) riding position recommendation method and device, electronic equipment and storage medium
CN105973239A (en) Method for searching shortest path of unmanned aerial vehicle
Meghjani et al. Multi-robot exploration and rendezvous on graphs
CN101840202A (en) Functional block intelligent wiring method in modeling of control system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
C41 Transfer of patent application or patent right or utility model
TR01 Transfer of patent right

Effective date of registration: 20151223

Address after: The South Road in Guangdong province Shenzhen city Fiyta building 518057 floor 5-10 Nanshan District high tech Zone

Patentee after: Shenzhen Tencent Computer System Co., Ltd.

Address before: Shenzhen Futian District City, Guangdong province 518044 Zhenxing Road, SEG Science Park 2 East Room 403

Patentee before: Tencent Technology (Shenzhen) Co., Ltd.