Ignore:
Timestamp:
01/15/07 16:28:59 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r1951 r1981  
    23532353} 
    23542354 
    2355  
    2356 } 
    2357  
     2355/* 
     2356int inline GetIntersection(const float fDst1,  
     2357                                                   const float fDst2,  
     2358                                                   const Vector3 p1,  
     2359                                                   const Vector3 p2,  
     2360                                                   const Vector3 &hit)  
     2361{ 
     2362        if ((fDst1 * fDst2) >= 0.0f)  
     2363                return 0; 
     2364     
     2365        if (fDst1 == fDst2)  
     2366                return 0;  
     2367     
     2368        hit = p1 + (p2 - p1) * (-fDst1 / (fDst2 - fDst1)); 
     2369         
     2370        return 1; 
     2371} 
     2372 
     2373 
     2374int inline InBox( CVec3 Hit, CVec3 B1, CVec3 B2, const int Axis) { 
     2375if ( Axis==1 && Hit.z > B1.z && Hit.z < B2.z && Hit.y > B1.y && Hit.y < B2.y) return 1; 
     2376if ( Axis==2 && Hit.z > B1.z && Hit.z < B2.z && Hit.x > B1.x && Hit.x < B2.x) return 1; 
     2377if ( Axis==3 && Hit.x > B1.x && Hit.x < B2.x && Hit.y > B1.y && Hit.y < B2.y) return 1; 
     2378return 0; 
     2379} 
     2380 
     2381// returns true if line (L1, L2) intersects with the box (B1, B2) 
     2382// returns intersection point in Hit 
     2383int CheckLineBox( CVec3 B1, CVec3 B2, CVec3 L1, CVec3 L2, CVec3 &Hit) 
     2384{ 
     2385if (L2.x < B1.x && L1.x < B1.x) return false; 
     2386if (L2.x > B2.x && L1.x > B2.x) return false; 
     2387if (L2.y < B1.y && L1.y < B1.y) return false; 
     2388if (L2.y > B2.y && L1.y > B2.y) return false; 
     2389if (L2.z < B1.z && L1.z < B1.z) return false; 
     2390if (L2.z > B2.z && L1.z > B2.z) return false; 
     2391if (L1.x > B1.x && L1.x < B2.x && 
     2392    L1.y > B1.y && L1.y < B2.y && 
     2393    L1.z > B1.z && L1.z < B2.z)  
     2394    {Hit = L1;  
     2395    return true;} 
     2396if ( (GetIntersection( L1.x-B1.x, L2.x-B1.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) 
     2397  || (GetIntersection( L1.y-B1.y, L2.y-B1.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 ))  
     2398  || (GetIntersection( L1.z-B1.z, L2.z-B1.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))  
     2399  || (GetIntersection( L1.x-B2.x, L2.x-B2.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 ))  
     2400  || (GetIntersection( L1.y-B2.y, L2.y-B2.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 ))  
     2401  || (GetIntersection( L1.z-B2.z, L2.z-B2.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))) 
     2402        return true; 
     2403 
     2404return false; 
     2405} 
     2406*/ 
     2407 
     2408} 
     2409 
Note: See TracChangeset for help on using the changeset viewer.