Ignore:
Timestamp:
11/28/06 19:46:36 (18 years ago)
Author:
bittner
Message:

global lines support

File:
1 edited

Legend:

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

    r1772 r1824  
    23102310} 
    23112311 
    2312  
    2313 } 
    2314  
     2312Vector3 
     2313AxisAlignedBox3::GetUniformRandomSurfacePoint() const 
     2314{ 
     2315        // get face based on its surface area 
     2316        float pdf[7]; 
     2317        pdf[0] = 0.0f; 
     2318        int i; 
     2319        for (i=0; i < 6; i++) { 
     2320                pdf[i+1] = pdf[i] + GetFace(i).GetArea(); 
     2321        } 
     2322         
     2323        float x = RandomValue(0, pdf[6]); 
     2324        for (i=0; i < 6; i++) { 
     2325                if (x < pdf[i]) 
     2326                        break; 
     2327        } 
     2328 
     2329        const int idx = i-1; 
     2330         
     2331        const Rectangle3 face = GetFace(idx); 
     2332         
     2333        Vector3 point = Vector3(0,0,0); 
     2334        float sum = 0.0f; 
     2335 
     2336        for (i = 0; i < 4; ++ i)  
     2337        { 
     2338                const float r = RandomValue(0, 1); 
     2339                sum += r; 
     2340                point += face.mVertices[i] * r; 
     2341        } 
     2342 
     2343        point *= 1.0f / sum; 
     2344 
     2345        //normal = face.GetNormal(); 
     2346 
     2347        return point; 
     2348} 
     2349 
     2350 
     2351} 
     2352 
Note: See TracChangeset for help on using the changeset viewer.