Intersecting an A-A Cube

1 / 6

# Intersecting an A-A Cube - PowerPoint PPT Presentation

Intersecting an A-A Cube. ?. Axis-Aligned Cube. x,y = +/- 0.5. Axis-Aligned Cube. float s[3],d[3]; // R(t) = s + t*d float toutin[3],tinout[3]; // hold 3 intersections (t values) Int inout,outin; // indices into t arrays. Axis-Aligned Cube.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' Intersecting an A-A Cube' - clayton-bryan

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

### Intersecting an A-A Cube

?

Axis-Aligned Cube

x,y = +/- 0.5

Axis-Aligned Cube

float s[3],d[3]; // R(t) = s + t*d

float toutin[3],tinout[3]; // hold 3 intersections (t values)

Int inout,outin; // indices into t arrays

Axis-Aligned Cube

For each boundary plane

inout = outin = 0;

if (fabs(d[0]) > epsilon) {

t = (-0.5 - s[0])/d[0];

if (s[0]<-0.5) toutin[outin++] = t;

else tinout[inout++] = t;

}

else { // ray parallel to plane

if (s[0] < -0.5) <no intersection at all>

else <ignore this limit>

}

Axis-Aligned Cube

in 3D, up to 3 intersections

tinout[3]

toutin[3]

// find largest out-to-in, smallest in-to-out

toi = toutin[0];

If ((outin==2)&&(toutin[1] > toi)) toi = toutin[1];

Tio = tinout[0];

If ((inout==2)&&(tinout[1] > tio)) tio = tinout[1];

If (toi < tio) t = toi;

Axis-Aligned Cube

If start inside, need first in-to-out intersection

With this code, how do you tell if you started inside?