BVBV Intersection Tests YoonSik Shim Graphics Lab Korea
BV-BV Intersection Tests Yoon-Sik Shim Graphics Lab. Korea Univ.
Theorem § Separating Axis Theorem § For any two, arbitrary, convex, disjoint polyhedra, A and B, there exists a separating axis where the projections of the polyhedra, which form intervals on the axis, are also disjoint. If A and B are disjoint, then they can be separated by an axis that is orthogonal(i. e. , by a plane that is parallel) to either 1. a face of A, or 2. a face of A, or 3. An edge from each ployhedron cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 2
Sphere / Box Intersection § Idea : find point on the AABB that is closest to the sphere’s center c. bool Sphere. AABB_intersect ( c , r , A ) returns ({OVERLAB, DISJOINT}) d = 0 for each i {x, y, z} if ( ci < aimin ) d = d + ( ci - aimin )2 else if ( ci > aimax ) d = d + ( ci - aimax )2 if ( d > r 2 ) return (DISJOINT) return (OVERLAB) cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 3
AABB / AABB Intersection § Loop over all three standard axis directions x, y, and z. bool AABB_intersect ( A, B ) returns ({OVERLAB, DISJOINT}) for each i {x, y, z} if ( aimin > bimax or bimin > aimax ) return (DISJOINT) return (OVERLAB) cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 4
k-DOP / k-DOP Intersection § As simple as AABB intersection bool KDOP_intersect ( d 1 A, min, … , dk/2 A, min, d 1 A, max, … , dk/2 A, max, d 1 B, min, … , dk/2 B, min, d 1 B, max, … , dk/2 B, max ) returns ({OVERLAB, DISJOINT}) for each i {1, …, k/2} if ( di. B, min > di. A, max or di. A, min > di. B, max ) return (DISJOINT) return (OVERLAB) cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 5
OBB / OBB Intersection § Determining whether OBBs A and B overlap Faces s A B t p q Separating Axis cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 6
OBB / OBB Intersection § Intersection test of three-dimentional OBBs § OBB B is represented relative to A, with a translation t and rotation matrix R § 3 from faces of A § au , av , aw § 3 from faces of B § bu , bv , bw § 9 from combinations of edges from A & B § Total : 3 + 9 = 15 axes § cij = ai x bj i = { u , v , w } and j = { u , v , w } cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 7
OBB / OBB Intersection § 2 D expression B hv. Bbv A hu. Bbu t hu. Aau hv. Aav r. A r. B t·l cgvr. korea. ac. kr l Graphics Lab. / Korea Univ. 8
OBB / OBB Intersection l : a separating axis, : i {x, y, z} r A = h i. A | a i l | r B = h i B| b i l | if | t l | > r. A + r. B then OBBs are disjoint Let l = au : (au = (1, 0, 0)T) then, | t l | = | t a u | = | tx | r A = h i. A | a i a u | = h u A r. B = hi. B| bi au | = hu. B |bxu| + hv. B |bxv| + hw. B |bxw| = hu. B |r 00| + hv. B |r 01| + hw. B |r 02| cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 9
OBB / OBB Intersection R= r 00 r 01 r 02 r 10 r 11 r 12 = ( bu bv bw ) ▶ rotation matrix r 20 r 21 r 22 relative A Disjointness test for l = au |tx|> hu. A +hu. B |r 00| + hv. B |r 01| + hw. B |r 02| Same manner for l = av and l = aw cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 10
OBB / OBB Intersection Next, test for B’s axis : for l = bu | t l |= | t bu | = |txbxu +tybyu +tzbzu| = |txr 00 +tyr 10 +tzr 20| r. A = hi. A| ai l |= hi. A| ai bu | = hu. A|bxu| + hv. A|byu | + hw. A|bzu | = hu. A|r 00| + hv. A|r 10| + hw. A|r 20| r. B = hi. B| bi l |= hi. A| bi bu |= hu. B |txr 00 +tyr 10 +tzr 20| > hu. A|r 00| + hv. A|r 10| + hw. A|r 20| + hu. B cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 11
OBB / OBB Intersection Next, test for edge combination : for l = au bv | t l |= | t (au bv)| = | t (0 -bzv byv)| = | tzbyv – tybzv | = | tzr 11 – tyr 21 | r. A = hi. A| ai l |= hi. A| ai (au bv)| = hi. A| bv (au ai)| = hv. A| bv aw|+hw. A| bv av| = hv. A|bzv|+hw. A|byv| = hv. A|r 21|+hw. A|r 11| cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 12
OBB / OBB Intersection r. B = hi. B| bi l |= hi. B|bi (au bv)| = hi. B|au (bi bv)| = hu. B|au bw|+hw. B|au bu| = hu. B|bxw|+hw. B|bxu| = hu. B|r 02|+hw. B|r 00| |tzr 11 – tyr 21| > hv. A|r 21|+hw. A|r 11|+hu. B|r 02|+hw. B|r 00| Same manner for other 8 combinations cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 13
View Frustum Intersection § BV / View Frustum intersection § We determine whether the BV is totally inside(inclusion), or totally outside(exclusion), or whether it intersects the frustum top far left right near cgvr. korea. ac. kr bottom Graphics Lab. / Korea Univ. 14
View Frustum Intersection The complete test : exclusion / intersection § Intersection may be considered too costly to compute then the test is simplified : exclusion / inclusion test § § Fully inside BV is considered intersection § Intersecting BV is considered fully inside § To decrease computing cost, we transform the test from a BV / frustum test to point / volume test cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 15
View Frustum Intersection § Extended volume by BV point / volume test cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 16
View Frustum Intersection § Symmetric frustum octant test c c d cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 17
View Frustum Intersection § Box / frustum test C A B cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 18
Line / Line Intersection tests § Two dimensions § First method a a = 0 r 1(s) = o 1 + sd 1 r 2(t) = o 2 + td 2 r 1(s) = r 2(t) o 1 + sd 1 = o 2 + td 2 sd 1 d 2 = (o 2 - o 1) d 2 td 2 d 1 = (o 1 - o 2) d 1 s = ((o 2 - o 1) d 2 ) / (d 1 d 2 ) t = ((o 1 - o 2) d 1 ) / (d 2 d 1 ) cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 19
Line / Line Intersection tests § Second method r 1(s) = p 1 + s(p 2 - p 1) r 2(t) = q 1 + t(q 2 - q 1) r 1(s) = r 2(t) a = q 2 - q 1 b = p 2 - p 1 c = p 1 - q 1 d = -c a e = -c b f = -a b if ( f > 0 ) if ( d < 0 or d > f ) else if ( d > 0 or d < f ) return NO_INTERSECTION s = (-c a ) / ( b a ) = (-c a ) / ( a b ) = d / f t = ( c b ) / ( a b ) = e / f cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 20
Line / Line Intersection tests § Three dimensions a a = 0 r 1(s) = r 2(t) o 1 + sd 1 = o 2 + td 2 sd 1 d 2 = (o 2 - o 1) d 2 td 2 d 1 = (o 1 - o 2) d 1 s(d 1 d 2) = ((o 2 - o 1) d 2) (d 1 d 2) t(d 2 d 1) (d 1 d 2) = ((o 1 - o 2) d 1) (d 1 d 2) s = | o 2 - o 1 d 2 d 1 d 2 | / || d 1 d 2 ||2 t = | o 2 - o 1 d 2 | / || d 1 d 2 ||2 cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 21
Intersection between 3 planes point = [ (p 1 n 1)(n 2 n 3) + (p 2 n 2)(n 3 n 1) + (p 3 n 3)(n 1 n 2) ] / | n 1 n 2 n 3 | determinant ri(t) = tni ni x + di = 0 ni ri(t) + di = 0 tni ni + di = 0 t = -di pi = ri(-di ) = -dini cgvr. korea. ac. kr Graphics Lab. / Korea Univ. 22
- Slides: 22