[IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou,...

4
Application of Collision Detection Based on Projection Point to Driving Simultaion Chen-hua LI, Tong-de TAN, Xin-can ZHAO School of Information Engineering, Zhengzhou University Zhengzhou, China Email:[email protected], [email protected], [email protected] Abstract—Based on the designing requirement of virtual car driving simultaion system, a collision detection algorithm based on the model projection point was proposed referring to Moore and Wilhelms’ ideas of the virtual driving simulation system.The algorithmrationally distributes and minimizes the objects which are involved in calculation in different stages, decomposes the struction of scenes and re-organizes the the composition of modles. The experiments and analyses demonstrate that the new algorithm not only reduces the time of the collision detection, but also improves the accuracy of collision detection. Keywords- collision detection; viutual driving simultaion; Projection point; Moore; Wilhelms I. INTRODUCTION Whether in computer graphics, virtual reality, computer games or the fields of CAD/CAM, collision detection is always a very important issue.At present, collision detection between two given objects is divided into two phases of stepwise refinement and precise intersection, with the introduction of various optimization techniques to the two stages, the speed of collision detection can be improved. From the perpective of time, the basic collisions are mainly divided into: static, continuous and discrete collision detection algorithms [1] ;from the point of the space they can be divided into: imagespace based algorithm [2][3] and object- space based algorithm [4][5] .Most of the collision detection algorithms depend on the complexity of model, sometimes maintains a close relation with the topology of the model shape [6] .which makes the collision detection process complex, and imposes too many requirements on the model itself. Virtual driving simulation system is an interactive system encompassing much interacton and simulation; it allows the user to choose the model in model library, and randomly orgnizes scenes according to user requirements. Its characteristics are: random orgnization, complexity and diversity of composing elements, high repetition of models, disuniform of the models and dynamicchoice of the objects A collision detection algorithm is needed which can process diverse models, and avoid adding test difficultywhen the number of model is increased. This article refers to Moore and Wilhelms’ collision detection algorithm for triangulation of a surface, puts out a projection-point based collision detection algorithm which turns the relationships between triangular surfaces intoone between point and line Algorithm Overview.Moore and Wilhelms [6] made a collision detection algorithm focusing on triangulated surfaces.Due to that any surface can be expressed as a series of triangular patches,the collision detection algorithm has strong universality. the basic idea of Wilhelms and Moore‘s algorithm is intersection test between the trajectory of each vertex on a moving rigid body and each triangular faceon another moving or still rigid-body, if there is a valid intersection, then the two rigid body will collide, within such a period, they will not collide. Disadvantage of this method is that when the scene is a complex sculptured surface, surface triangulation may produce a large number of triangulars, which can significantly affects the efficiency of the algorithm. The main ideas of this algorithm is: If collision occurs between moving A and B, then there would be overlay between B and the projection of A on the plane parallel to A’s moving direction. If there is interacton beween a projection on the plane belonging to triangular faces within B’s valid range and the outline of A’s projection on the plane, then the collision between A and B can be predicted. This algorithm generally has two coordinate systems: the global coordinate system of scene and the local coordinate system of model.Model objects are stored separately, which has a separately coordinate systems, each object has only one model object when involved in the calculation. Read triangle patch information from model files,convert data from three- dimension into a two-dimension, get contour line extracted from object edge, convert the relationship between surface and surface into the relationship between lines and points, so as to simplify the calculation and improve accuracy. This algorithm is composed of three stages: Figure 1. Sketch of three phases 1) Pretreatment: the main goal of the preprocessing stage is reasonably decomposing and reorganizing scenes and 2012 Fifth International Symposium on Computational Intelligence and Design 978-0-7695-4811-1/12 $26.00 © 2012 IEEE DOI 10.1109/ISCID.2012.233 328 2012 Fifth International Symposium on Computational Intelligence and Design 978-0-7695-4811-1/12 $26.00 © 2012 IEEE DOI 10.1109/ISCID.2012.233 327 2012 Fifth International Symposium on Computational Intelligence and Design 978-0-7695-4811-1/12 $26.00 © 2012 IEEE DOI 10.1109/ISCID.2012.233 327

Transcript of [IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou,...

Page 1: [IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou, China (2012.10.28-2012.10.29)] 2012 Fifth International Symposium on Computational

Application of Collision Detection Based on Projection Point to Driving Simultaion

Chen-hua LI, Tong-de TAN, Xin-can ZHAO

School of Information Engineering, Zhengzhou University Zhengzhou, China

Email:[email protected], [email protected], [email protected]

Abstract—Based on the designing requirement of virtual car driving simultaion system, a collision detection algorithm based on the model projection point was proposed referring to Moore and Wilhelms’ ideas of the virtual driving simulation system.The algorithmrationally distributes and minimizes the objects which are involved in calculation in different stages, decomposes the struction of scenes and re-organizes the the composition of modles. The experiments and analyses demonstrate that the new algorithm not only reduces the time of the collision detection, but also improves the accuracy of collision detection.

Keywords- collision detection; viutual driving simultaion; Projection point; Moore; Wilhelms

I. INTRODUCTION Whether in computer graphics, virtual reality, computer

games or the fields of CAD/CAM, collision detection is always a very important issue.At present, collision detection between two given objects is divided into two phases of stepwise refinement and precise intersection, with the introduction of various optimization techniques to the two stages, the speed of collision detection can be improved. From the perpective of time, the basic collisions are mainly divided into: static, continuous and discrete collision detection algorithms[1];from the point of the space they can be divided into: imagespace based algorithm[2][3] and object-space based algorithm [4][5].Most of the collision detection algorithms depend on the complexity of model, sometimes maintains a close relation with the topology of the model shape[6].which makes the collision detection process complex, and imposes too many requirements on the model itself. Virtual driving simulation system is an interactive system encompassing much interacton and simulation; it allows the user to choose the model in model library, and randomly orgnizes scenes according to user requirements. Its characteristics are: random orgnization, complexity and diversity of composing elements, high repetition of models, disuniform of the models and dynamicchoice of the objects A collision detection algorithm is needed which can process diverse models, and avoid adding test difficultywhen the number of model is increased.

This article refers to Moore and Wilhelms’ collision detection algorithm for triangulation of a surface, puts out a projection-point based collision detection algorithm which turns the relationships between triangular surfaces intoone between point and line Algorithm Overview.Moore and Wilhelms[6] made a collision detection algorithm focusing on triangulated surfaces.Due to that any surface can be expressed as a series of triangular patches,the collision detection algorithm has strong universality. the basic idea of Wilhelms and Moore‘s algorithm is intersection test between the trajectory of each vertex on a moving rigid body and each triangular faceon another moving or still rigid-body, if there is a valid intersection, then the two rigid body will collide, within such a period, they will not collide. Disadvantage of this method is that when the scene is a complex sculptured surface, surface triangulation may produce a large number of triangulars, which can significantly affects the efficiency of the algorithm.

The main ideas of this algorithm is: If collision occurs between moving A and B, then there would be overlay between B and the projection of A on the plane parallel to A’s moving direction. If there is interacton beween a projection on the plane belonging to triangular faces within B’s valid range and the outline of A’s projection on the plane, then the collision between A and B can be predicted.

This algorithm generally has two coordinate systems: the global coordinate system of scene and the local coordinate system of model.Model objects are stored separately, which has a separately coordinate systems, each object has only one model object when involved in the calculation. Read triangle patch information from model files,convert data from three-dimension into a two-dimension, get contour line extracted from object edge, convert the relationship between surface and surface into the relationship between lines and points, so as to simplify the calculation and improve accuracy.

This algorithm is composed of three stages:

Figure 1. Sketch of three phases

1) Pretreatment: the main goal of the preprocessing stage is reasonably decomposing and reorganizing scenes and

2012 Fifth International Symposium on Computational Intelligence and Design

978-0-7695-4811-1/12 $26.00 © 2012 IEEE

DOI 10.1109/ISCID.2012.233

328

2012 Fifth International Symposium on Computational Intelligence and Design

978-0-7695-4811-1/12 $26.00 © 2012 IEEE

DOI 10.1109/ISCID.2012.233

327

2012 Fifth International Symposium on Computational Intelligence and Design

978-0-7695-4811-1/12 $26.00 © 2012 IEEE

DOI 10.1109/ISCID.2012.233

327

Page 2: [IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou, China (2012.10.28-2012.10.29)] 2012 Fifth International Symposium on Computational

extracting effective information according to customer-specified parameter s and stores them.

2) Scene traversal: traversing the scene structure chain got in the preprocessing phase to determine between which model objects the collision may occur.

3) The exact intersection test: in the level traverse stage if a collision is detected between model objects testing the point and line in the model got in the preprocessing phase any further, to determine whether valid collision may occur.

II. PRETREAMENT This stage's main role is to reduce the calculation of scene

traversing and intersection testing t. Main task in the preprocessing phase is: 1) Distribution model of organization: assuming the origin of the global coordinate system is at the Center of the ground, horizontal to the right of the X axis, Y axis perpendicularly pointing to inside, Z axis vertically upwards. According to coordinates of the model object centres in the coordinate system of the scene, relate model to four quadrant-chain.Each pointer of the last node of the last Linkelist points to the next head of the Linkelist. Typedef struct Model {

Int ModleNo; /*model number*/ Char* Name; /* model name*/

GLPoint CenterCoord; /*model center*/ GLuint numvertices; /*Number of vertices */

GLQuadPoint* vertices; /*vertex list*/ Float DMax; /*Range maximum distance*/

PPLine * LineLink; /*Range line list */ GLMmodel *next; };

Figure 2. Scene organization chart

2) Extracting points within moving object’s effective range and projecting them extracingt the useful information and assigning structure-data to models. As in virtual driving simulation, cars are reduced to a cube box, with “CarLength”, “CarWidth” and “CarHeight”. For each obstacle, in its local coordinate system, the range of car’s motion can be seen between as “Z>=0” and “Z<=CarHeight”.Putting effective lines and points into LineLink and PointLink, finding the longest diatance away from the model centers“Dmax”, and according to the projection point in the local coordinate system, assigning the points belonging to the vertices of the “XOY” to four

quadrantchains.Each pointer of the last node of the last linked list points to the next head of the linkelist. Typedef struct GLPointNode {

GLPoint *Point; //vertex node GLPointNode * next;

};

Figure 3. Model vertex organization chart

3) Finishing order, reduce duplication of information: as the existence of many repetive points in the chains, “LineLink” also has many repective segmentsfind, replace delete extra points and lines, reduce the amount of calculation.

III. SCENE TRAVERSAL Scene traversal's primary role is to try to find possible

objects which may collide with the moving object model within a short time.

The basic idea is motion projecting, traversing the quadrant chains according to priority under global two-dimensional coordinate system for moving objects in the scene , finding model potentially colliding with the moving object. In the Virtual driving simulation, follow the steps below to find:

1) get “ViewerPosition” which is the current view position, according to the car's direction of movement parameters such as “CarSpeed” and “CarLength” find the Center front” CarHeadPosition”, determine where “ModelQuad” locates in four quadrants.

2)orderly detecting ”ModelQuad”in the of model,”Model” whether it may collide with Car: by frame frequency,speed,and front’s location in large scene “O1 “calculating out after interval T the front’s new location “O3”, judging whether distance between coordinates of center of front “O1” and coordinates of Center of “Model” “O2” is greater than “Dmax+sqrt (POW(CarWidth/2,2) +Pow (S,2))”, if not there may occur collision.

Figure 4. Determine the collision between Car and Model

329328328

Page 3: [IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou, China (2012.10.28-2012.10.29)] 2012 Fifth International Symposium on Computational

V THE EXACT INTERSECTION TEST It was got from Scene traversal that collision may occur

between the moving object and “Model” in next T-time, in this stage what should be taken is to determin the exact point if the two will collide and crash.

General situation: In a very short period of time, two nearby objects are more likely to collide with each other than the further away one.So at first judge the obstacle moving objects close to moving objects, to a certain extent, reducing the amount of calculation, and saving time. So first accoding to movement object’s location in model Model, judging its locating quadrant, will object movement range projection turn and the quadrant top ideas chain table “XpointQuad” within of vertex and the “Model” of line chain LineLink for detection, as has vertex is located in object future t time movement range of projection within, or “LineLink” within of segment and object movement range projection exists effective intersection, is will occurs collision.Virtual driving simulation tests by following these steps:

1) Depending on where the “O1” in the local coordinate system of the “Model “of “Car” is, judge whiche “Xquad” it belongs.

2) Calculate the “o1” and “o3” in the testing “Modle” of the local coordinate system of the model coordinates “O1” and “O3”.Make text between the “line” nodes of “LineLink” and “Car” in the next T-time within the contours intersect the range.Assumes Car’ front ends of the projection line points in T-track within the time period for” L1”,” L2”.The cross point between line of “LineLink” and “LX” is “NewPoint”.if “d1” the distance between “NewPoint” and “L3” that projection lines of last Car head is not greator than “S”, “d2” the distance between “NewPoint” and “L4” that projection lines of next Car head is “S-d1”,and the position of “NewPoint”is between the two points of “Line”,there will be collision(S=T*| CarSpeed|).

Figure 5. Sketch of Line detection

3) Make collision detection between the node of “XpointQuad” and the rang of contour lines of Car coming in next T-time. Assumes there is a collision detection between the node “Point” of “XpointQuad”,if “d1” the distance between “L1” and “Point” is no more than “S”, “d2” the distance between “L2” and “Point” is no more than “S-d1”,and “d3” the distance between “Point” and“L3” is no more than “CarWidth”,and “d4” the distance between “L4” and “Point” is no more than “CarWidth-d3”, there will be collision,as figure 6:

Figure 6. Sketch of Point detection

VI KEY DESIGN AND IMPLEMENTATION OF ALGORITHM The key to success or failure of the algorithm is whether

it can get the result of collision, real-timely and exactly in intersection testing phase, which means there should be as little as possible, but also plenty of information in preprocessing stage.So In the preprocessing stage the following key points are essemtial:

1) How to extract the information of surface triangular patch: The general Storage method of 3-dimension model is by the way of underlying triangle surface tablets. The format of 3-dimensional model file main have: 3Dc, .3ds, .DXF, .obj and so on. For obj files, users can directly use WordPad to open it for viewing and editing. Therefor, after converting files in other formats to files in the format of. Obj, the model of triangular patch data could be read.

2)Seeking the new slice information intercepted by plane “Z=CarHeight”: the new section informationformed by plane intercepting is required in testing phase,through directly strikeing the surface information and Intersection information is complex.On the other hand,what we need later is contour information,So make the model Subdivided,convert the intersection between plane and model to the intersection of plane and triangular patch, which just need to get the new cross points and new lines througt triangular patch. From figure 7,we can get two intersect situations between the plane (Z=CarHeight) and the triangular face (ABC):If there are two points above “Z”,join the two new points(N1,N2) into corresponding quadrant vertex list and put the new line into “LineLink”;if there is just one point above “Z”,join the two new points into corresponding quadrant vertex list and put the new lines into “LineLink”.

Figure 7. the two cases of triangular face cut

330329329

Page 4: [IEEE 2012 5th International Symposium on Computational Intelligence and Design (ISCID) - Hangzhou, China (2012.10.28-2012.10.29)] 2012 Fifth International Symposium on Computational

3) Saving of effective information: the information of extracted vertex and lines would occupy a lot of memory of computer, expecially in the case of numberous models and intensive complexitly which not noly wasts resources, but also reducesthe effective of the algorithm. If the valid information can be stored in a file formated “.txt” , readonly when used, which would not only save a large part of the memory, but also save a lot of time in preprocessing phase If the same model and parameters of moving object does not change next time .In the next figure,the sorted information about a plane intercepted by plane(Z=2.0) was saved,the first line of figure is the most Length(DMax) between the vertex and center of box,and the vertex information in the quadrant were ordered:

Figure 8. Example of information effective

After the preprocessing stage, each model object,in the end, has three related files: original model files which is for reading model object; converted “.obj” file, which is for reading the triangle patch information;the “. Txt” file which is used to store information of vertices and lines segment.

VII RESULTS AND ANALYSIS This article is implemented on the platform of Visual

Studio 2010, Open Scene Graph (OSG for short). Hardware environment for processor: Intel (R) Core (TM) 2 CPU [email protected], memory: 2G. Display card: NVIDIA GeForce 6800. Compared with the traditional Hierarchical Bounding Box algorithm testing, the result is shown:

62 61 60 5854

4943

32

62 61 5955

5044

36

24

0

10

20

30

40

50

60

70

0.50 1.00 1.50 2.00 2.50 3.00 3.50 4.00

aver

age

fps

number of triangular patch 105

Projection Point Hierarchical bounding box

Figure 9. Two algorithms for virtual driving simulation

From the figure 9 we can see that: 1) As the collision detection algorithm based on the

projection point detection , the objects are limited to the

range of of motion, the participation operational data should not significantly increase as the increase of number of triangular patches, compared with the collision detection algorithm of traditional hierarchical bounding box, algorithm based on the projected point detection has better stability.

2) The function objects for the project point algorithm are just points and line segment regardless of the specific shape of models,So in dealing with irregular models, it have greater fitness.

3) During the testing process,something was found: in traditional bounding algorithm, if the instruction of model is not rigorous,the viewer wouldpenetrate the model easily.while,the detectionn objects are range projection contour in this algorithm, so there will not occur Penetration phenomena or invalid collisions.

VIII CONCLUSIONS AND OUTLOOK The algorithm put most of workload to the preprocessing

phase, saving more calculation time and workload in the exact intersection test phase. But if the number of model is large and the composition is more complicated, lots of time consumed by the preprocessing phase time would be out of bear. So taking the effective information of model in a short time with the help of other way is the work in the next phase.

In the exact intersect testing stage, though finishing and sorting were made , the amounts of information of vertex and line segment is still very large, the composition of line segment is very complex,not easy to classify and differentiate, which takes a lot of calculations to the system. Besides, if implementing this algorithm by computer graphics hardware GPU, CPU would be liberated on the one hand, on the other hand real-time performance and accuracy can also be further improved by taking advantage of GPU's parallelism.

REFERENCES [1] Zou Yisheng,Ding Guofu . A collision detection algorithm based on

image space, Journal of system simulation.2011 [2] Zhao Wei. Research on Fast Collision Detection Algorithm Based on

Parallelism [D]. Jilin University, 2009 [3] MA Deng-wu, YE Wen, LI Ying. Survey of Box-based Algorithms

for Collision Detection[J]. Journal of System Simulation, 2006,18(4):1058~1064

[4] F.Thomas,C.Torras.3Dcollision Deteetion:ASurvey[J] .ComPuterGraPhies,2001,25(2):269-285

[5] Xiao Peng,Liu Geng-dai,Xu Ming-liang. The Guide of 3D Rendering Engine Programming in OSG[M]. Beijing, Tsinghua University Press, 2010

[6] Moore M, Wilhelms J. Collision detectionand response for computer animation[J].Computer Graphics, 1988,22(4):289-298

331330330