US 6518966 B1 Abstract Two three-dimensional bodies using the computer graphics are shown on the screen in an overlapping manner. The two bodies may be located one in front of the other or one inserted into the other. The latter is called collision. The collision is detected by comparing a line segment extending in a depth direction of the first body, and a line segment extending in a depth direction of the second body. Both line segments are in alignment with a pixel of a projected image where the two bodies are overlapping.
Claims(4) 1. A collision detection device for detecting a collision between first and second bodies displayed on a screen, comprising:
a first memory for storing first and second end positions of a first line segment as a front depth data A_front and a back depth data A_back, respectively, the first line segment extending in a depth direction of the first body, and being in alignment with a pixel of a projected image;
a second memory for storing first and second end positions of a second line segment as a front depth data B_front and a back depth data B_back, respectively, the second line segment extending in a depth direction of the second body, and being in alignment with the pixel;
a reading arrangement for reading the first and second end positions of the first line segment and the first and second end positions of the second line segment;
a line overlap detector for detecting whether said first and second line segments are at least partially overlapping using said depth data A_front, A_back, B_front and B_back; and
a collision detector for detecting a collision of the first and second bodies when the fit and second line segments are overlapping,
wherein said line overlap detector is operable to calculate a first equation A_front−B_back and a second equation A_back−B_front, and
wherein said line overlap detector is operable to detect a line overlap when the signs of the calculated results of the first equation and the second equation are not the same.
2. A collision detection device for detecting a collision between first and second bodies displayed on a screen, comprising;
a first memory for storing first and second end positions of a first line segment as a front depth data A_front and a back depth data A_back, respectively, the first line segment extending in a depth direction of the first body, and being in alignment with a pixel of a projected image;
a second memory for storing first and second end positions of a second line segment as a front depth data B_front and a back depth data B_back, respectively, the second line segment extending in a depth direction of the second body, and being in alignment with the pixel,
a reading arrangement for reading the first and second end positions of the first line segment and the first and second end positions of the second line segment;
a line overlap detector for detecting whether said first and second line segments are at least partially overlapping using said depth data A_front, A_back, B_front and B_back; and
a collision detector for detecting a collision of the first and second bodies when the first and second line segments are overlapping,
wherein said line overlap detector is operable to determine whether a first condition A_front <B_back is satisfied and whether a second condition A_back>B_front is satisfied, and
wherein said line overlap detector is operable to detect a line overlap when the first condition and the second condition are satisfied.
3. A collision detection method for detecting a collision between first and second bodies displayed on a screen, comprising:
storing first and second end positions of a first line segment as a front depth data A_front and a back depth data A_back, respectively, the first line segment extending in a depth direction of the first body, and being in alignment with a pixel of a projected image;
storing first and second end positions of a second line segment as a front depth data B_front and a back depth data B_back, respectively, the second line segment extending in a depth direction of the second body, and being in alignment with said pixel;
reading the first and second end positions of the first line segment and the first and second end positions of the second line segment;
detecting whether the first and second line segments are at least partially overlapping using the depth data A_front, A_back, B_front and B_back; and
detecting a collision of the first and second bodies when the first and second line segments are overlapping,
wherein said detecting whether the first and second line segments are at least partially overlapping farther comprises calculating a first equation A_front−B_back and a second equation A_back−B_front, and
and wherein a line overlap is detected when the signs of the calculated results of the first equation and the second equation are not the same.
4. A collision detection method for detecting a collision between first and second bodies displayed on a screen, comprising:
storing first and second end positions of a first line segment as a front depth data A_front and a back depth data A_back respectively, the first line segment extending in a depth direction of the first body, and being in alignment with a pixel of a projected image;
storing first and second end positions of a second line segment as a front depth data B_front and a back depth data B_back, respectively, the second line segment extending in a depth direction of the second body, and being in alignment with said pixel;
reading the first and second end positions of the first line segment and the first and second end positions of the second line segment;
detecting whether the first and second line segments are at least partially overlapping using the depth data A_front, A_back, B_front and B_back; and
detecting a collision of the first and second bodies when the first and second line segments are overlapping,
wherein said detecting whether the first and second line segments are at least partially overlapping further comprises determining whether a first condition A_front<B_back is satisfied and whether a second condition A_back>B_front is satisfied, and
wherein the first and second line segments are detected to be at least partially overlapping when the first condition and the second condition are satisfied.
Description 1. Field of the Invention The present invention relates to collision detection for three-dimensional shapes used in computer graphics and the like and for images of the like that have depth and are obtained with range finders, stereoscopic vision, and the like. 2. Description of the Related Art For some time, formats for collision detection have been used that employ geometric shapes with computer graphics, CAD, and the like as the format for the detection of contact and mutual interference between bodies and components. An explanation will be given regarding polygon model collision detection in which the three-dimensional shape of a body is approximated by small planes using computer graphics. To detect whether collisions have occurred among polygon models, the detection of collisions between each of the planes (polygons) is carried out for all polygon combinations. Therefore, an explanation will be given using figures regarding a method for collision detection for two triangular polygons. FIG. 17A shows a state in which two triangular polygons FIG. 17B shows the state in which one edge where x0, y0, and z0 are coordinates of a point on the straight line; and i, j, and k are direction vectors of the straight line on the other hand, the equation of a plane on the triangular polygon
where a, b, and c are normal vectors to the surface, and d is the distance from the origin. Therefore, from Equation 1, Equation 2, Equation 3 and Equation 4, the parameter t of the straight line at the point of intersection
By means of the substitution of the t that has been derived in Equation 1, Equation 2 and Equation 3, it is possible to derive the coordinates of the point of intersection Actually, since the point of intersection is calculated only from the plane and straight-line parameters, it is necessary to next investigate whether the point of intersection is within the line segment
and
it can be detected that it is on (within) the line segment. In addition, with regard to the detection as to whether the point The above detection processing is carried out for the entire group of polygons constituting a model. By this means, two-polygon model collision detection is done. However, the above-mentioned method has had a problem in that the processing time increases in proportion to the complexity of the three-dimensional shape. With the polygon model, as the shape becomes complex, the number of polygons with which detailed shapes are represented increases, and the number of comparison polygon combinations for the collision detection increases. In particular, with regard to each of the pixels of an image measured with a range finder or the like, when the collision detection between range images (or depth images) at a given distance from the camera, or between the range images and the polygon models is considered, if the range images are thought of as being composed of rectangular polygons whose number is commensurate with the number of image pixels, collision detections for the combinations of polygons is required in an amount commensurate with the number of the pixels of the image. For example, let us assume that each pixel of a distant image is a rectangular polygon. In a worst-case scenario, an established collision involving a single triangular polygon of another body requires that the point of intersection in Equation 5 be calculated and the two magnitudes from Equations (6) and (7) for detecting the positions inside and outside of line segments be compared the number of times equal to the number of pixels, assuming that the number of sides is three. In addition, for the detection involving the interior of a rectangular polygon, it must be carried out the same number of times as the number of pixels for each of the four apex points. A method may also be considered where a portion obtained by representing a range image as a plane rather than a polygon for each image is replaced with a large polygon, and the number of polygons is reduced. However, there is a problem in that this increases the processing for the polygon reduction. In addition, collision detection must involve conversion to a polygon model when such detection involves solid models in which three-dimensional shapes rather than range images are represented as solid bodies whose interiors are filled with matter, as well as boxel models and various other models in which computer graphics other than meta-balls or other such polygon models are used. There has been a problem in that, with the increase of the conversion processing and the differences in the model representation methods, there is an extraordinary increase in the number of polygons with the polygon model for shapes that can be represented simply by other models. As an example of the latter problem, the globe is a fundamental shape for the meta-ball or the like, and can be simply described. However, with the polygon model, many polygons are required to describe a globe that has some degree of smoothness. An object of the present invention is to allow the collision detection for bodies of complex shapes to be carried out with an amount of processing that is proportionate to the number of pixels of the projected image irrespective of the complexity of the body by carrying out collision detection in which arrays are correlated to each of the pixels of a projected image of a body without a collision detection of geometric shapes such as polygons. In order to the attain the stated object, the present invention dispenses with the use of collision detection between polygons and entails instead performing collision detection that is independent of the complexity of the body shape by using body regions obtained by projecting bodies subject to collision detection onto the pixels of projected images, and by employing a depth array in which distances from an arbitrary point or plane are arranged for each of the pixels of th e projected images. FIG. 1 is a diagram of the structure and the flow of the processing of the embodiments of the present invention; FIG. 2A is an explanatory diagram depicting the relationships between the bodies, the projected images and the depth arrays; FIG. 2B is a diagram showing the front depth value and the back depth value; FIG. 3 is a diagram depicting the data structure of one element of a depth array; FIG. 4A is a diagram showing a U-shaped body and its projected image on the screen; FIG. 4B is a diagram showing a column shaped body and its projected image on the screen; FIG. 4C is a diagram of the manner in which two bodies collide and their projected image on the screen; FIG. 5A is a diagram showing the collision of the two bodies viewed from top; FIG. 5B is an explanatory diagram showing the depth of each body shown in FIG. 5A; FIGS. 6A, FIG. 7 is a diagram showing the hierarchical arrangement of the depth arrays used in the second embodiment of the invention; FIG. 8 is a flow chart of collision detection using the hierarchical depth arrays; FIG. 9A is a perspective view of a ball and a plate colliding; FIG. 9B is a diagram showing the screen view of the two bodies shown in FIG. 9A; FIG. 10A is a diagram showing entered front depth values of the ball in the hierarchical depth arrays; FIG. 10B is a diagram showing entered back depth values of the ball in the hierarchical depth arrays; FIG. 11A is a diagram showing entered front depth values of the plate in the hierarchical depth arrays; FIG. 11B is a diagram showing entered back depth values of the plate in the hierarchical depth arrays; FIGS. 12A, FIGS. 17A, Below, an explanation of the embodiments of the invention will be given using FIG. FIG. 1 is a flow chart that shows an outline of the case where the collision detection processing of the present invention has been applied for two bodies. In FIG. 1, In memory In the collision detection means Next a detailed explanation will be given regarding the collision detection process. FIG. 2A is a drawing that shows a relationship between a U-shaped body The regions of the body that are correlated to one pixel A Z buffer for storing minimum depth values corresponding to each of the pixels of a synthetic image are often used when such back and front depth values are used to synthesize a three-dimensional shape into a two-dimensional image by computer graphics or the like. The values in the Z buffer correspond to the minimum front depth values. In the Z buffer, the values are updated with the minimum values, and the front and back depth values can be retrieved by expanding all the Z values of the body surface for storage purposes. In the case of a solid model or the like, it is possible to obtain the front and back depth values more directly from the model because of the availability of data concerning the interior of the body. The values can also be obtained with the aid of range image measurement systems that employ laser light, stereoscopic measurement systems using two cameras that have been arranged leaving an interval, and the like. A range image that holds the depth data for each pixel of the image can be viewed as a single array of minimum front depth values. In those cases where an actual reproduction of the scenery or the like is measured, the entire body is viewed as being filled from the front to the back, and the processing may be done by viewing it as one combined back and front depth array in which the back depth value is infinite. Or, by changing the direction 180 degrees and taking the measurements from two directions, it is possible to obtain the minimum front depth value and the maximum back depth value. FIG. 3 is a diagram that shows the data structure of an element of a depth array. Next, the previously mentioned depth array will be used and an explanation will be given regarding the method of collision detection for each pixel. FIGS. 4A, FIG. 5A shows a cross-sectional view taken along a line FIG. 5B shows the front depth value (black dot) and back depth value (white dot) of bodies The collision detection for each pixel of step Next, an explanation Will be given regarding the inspection of the overlapping of the line segment According to the present invention, a positivity or negativity sign (+ or −) of the following two formulas is considered.
When two bodies, such as bodies On the other hand, when two bodies, such as bodies If the positive sign is expressed by “1” and the negative sign is expressed by “0”, an EXCLUSIVE OR taken between the signs of the calculated results of equations (8) and (9) will be “0” when the signs are both pluses (+, +) or both minuses (−, −) or will be “1” when the signs are plus and minus (+, −) or minus and plus (−, +). The case where the value of equation (8) or equation (9) is 0 is a case where there is a contact between two bodies, and this can be included in a collision. Therefore, a collision detection can be made for a group of line segments by performing two subtractions, two positive and negative detections, and one EXCLUSIVE-OR operation. To detect the collision between two bodies, the overlap between two line segments, such as line segments
When the two equations (10) and (11) are satisfied, two line segments overlap, and therefore, two bodies collide. For example, in the cases of FIGS. 6B,
is obtained, two objects contact at either end of the line segment. Thus, such a case is included as one style of collision. It is possible that the contact is not included in the collision. Therefore, in this case, with respect to the two line segments, two comparisons and one logic AND are carried out to detect the collision. If at least one collision detection is obtained for one pixel, it is possible to detect a collision between two bodies. Furthermore, if the above detection is carried out for all of the pixels in the overlapping area, the portion of the two bodies where the collision is taking place can be detected precisely. The software program for this kind of FIG. 1 processing can be written to recording media and distributed in the market. The same is true for the aspect of the embodiment below. With the previously mentioned collision detection, in a case where bodies have not collided, the detection is not output until detections have been made for all of the pixels of the overlapping region, and the amount of processing increases with an increase in the overlapping region. An explanation will be given below regarding a method in which a detection is made before all the pixels are processed when there is no collision and the elements are completely separated (their irregularities are not combined). FIG. 7 is an explanatory diagram of the minimum depth value hierarchy of a depth array. The minimum value of the depth array is the front depth value 1 according to In the same manner, the maximum depth values of the depth array are made into a hierarchy. The maximum values of the depth array for each pixel become the final elements of the data of FIG. 3, and this value also exists without exception no matter what kind of case. When maximum depth values are made into a hierarchical arrangement, the top level is constituted as a value which is the maximum value of the region that corresponds to the opposite of the previously mentioned minimum depth hierarchy. Each of the levels forms a circumscribed shape of the back. By means of a comparison from the uppermost levels of these two maximum and minimum depth hierarchies, it is possible to carry out fewer operations when no collisions occur among separated bodies. For example, if the bodies are completely separated, all of the maximum depth values of the body that is in front will be values that are smaller than any of the minimum depth values of the body that is in the rear. Therefore, if a comparison is made between the hierarchies with which the entire image has been integrated, such as An explanation of the collision detection processing flow that em ploys hierarchical depth arrays will be given using the figures. FIG. 8 is a flow-chart of the processing, and FIGS. 9A to FIG. 9A is a schematic diagram that shows the state in which a sphere and a rectangular plate have collided. FIG. 9B shows projected images thereof. In FIG. 10A, the hierarchical depth maps that correspond to the projected image As shown in FIG. 10B, in the same manner, array elements In FIG. 11A, the hierarchical depth arrays that correspond to the depth values of the projected image In FIG. 11B in the same manner, A description will now be given concerning a procedure for detecting collisions using the hierarchical depth arrays in FIGS. 10A, ( while Equation (9) is positive. ( Because the signs are different, there is a possibility that a collision has occurred. Actually, even if there is a collision in the upper levels, if the regions of the lower levels are divided finely, there will also be cases where there is no collision. Conversely, if no collision has occurred in the circumscribed shape encircled by the maximum and minimum values in the absence of a collision, no collision will be detected even if a division of the shape that is finer than that is done. Processing can therefore be terminated at this stage, if no collision is detected at Next, in the case of a collision, all of the groups that have a collision are extracted in process To continue processing at a lower level, larger surface areas of regions corresponding to the initially lowermost level are replaced with regions corresponding to the next lowest level from among the corresponding elements in process In For Equation (8) ( For Equation (9) ( With groups For Equation (8) ( For Equation (9) ( With groups For Equation (8) ( For Equation (9) ( Therefore, lower level collision detection is carried out with the single groups of Therefore, Thus, the present invention allows collision detection to be performed by a routine that is proportionate to the number of pixels in a projected image without the increase in the volume of processing due to the complexity of the geometric shapes, as is the case with the detection of collisions among polygons. In addition, the pixels of a projected image can be processed at a higher speed due to shared processing, which is achieved by employing a routine that is largely similar to the image composite processing performed using the Z buffer of computer graphics or the like, and by incorporating collision detection into the composite processing of images. Also, in the case where there are some movements in the scene expressed by forming a plurality of frames and synthesizing moving objects, many frames can be prepared without any collision occurring between the objects. In such a case, by the use of hierarchical depth maps as described in the second embodiment, the detection of the collision can be done in a very short time. Thus, the collision detection of one frame can be done in a very short time. Patent Citations
Non-Patent Citations
Referenced by
Classifications
Legal Events
Rotate |