Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!ndcheg!uceng!achhabra From: achhabra@uceng.UC.EDU (atul k chhabra) Newsgroups: comp.graphics Subject: ray/bounding box intersection Keywords: ray tracing, bounding box Message-ID: <857@uceng.UC.EDU> Date: 11 Apr 89 21:30:37 GMT Distribution: na Organization: Univ. of Cincinnati, College of Engg. Lines: 70 I have a question about checking for ray/bounding box intersection in ray tracing. Rogers ("Procedural Elements for Computer Graphics," 1985, pp. 299) suggests a transformation comprising of translation and rotations about the coordinate axes, in order to make the ray coincident with the z-axis. This transformation is applied to both the ray and the bounding box. Rogers goes on to say that the ray intersects the box if, in the translated and rotated coordinate system, the signs of x_min and x_max AND of y_min and y_max are opposite. He illustrates this with a ray-box configuration which, after aligning the ray with the z-axis, looks as shown below. ^ y | | ------|------ | | | | | | x -----------------------> | | | | | | (z-axis perpendicular to the screen) ------|------ | | But what if the transformation leads to a configuration as shown below? In this case, you cannot infer anything about the ray/bounding box intersection from the values of x_min, x_max, y_min, and y_max. x_min and x_max have opposite signs. Also, y_min and y_max have opposite signs. Yet the ray (z-axis) does not intersect the bounding box (cube). ^ | y | ------------------ | / / \ | / / \ x -----|---/----------------/---------\------> | / / \ | / \ / | / \ ---|-------------- \ | \ / | \ / | \ \ / | \ \ / | \ \ / \ \ / ------------------ (z-axis perpendicular to the screen) (Say, a unit cube first translated, then rotated about the x-axis and next rotated about the y-axis, such that the same transformation makes the ray lie on the z-axis). Could some ray tracing guru clarify this? Am I using the right kind of transformations? In addition to determining whether the ray intersects the bounding box, I am also interested in computing the coordinates of the point of intersection closest to the origin of the ray. Could some kind soul email me a piece of code that does the computations for ray/bounding box intersection? Thanks, Atul --------------------------------------------------------------------------- Atul K. Chhabra INTERNET: achhabra@ucesp1.ece.uc.edu 811J Rhodes Hall, ML 030 (129.137.33.114) Dept. of Electrical & OR achhabra@uceng.uc.edu Computer Engineering (129.137.33.1) University of Cincinnati Cincinnati, OH 45221-0030 Phone: (513)556-4766 ---------------------------------------------------------------------------