Ignore:
Timestamp:
02/14/06 17:13:42 (18 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r256 r639  
    3131  return true; 
    3232} 
     33 
     34 
     35Vector3 Plane3::FindIntersection(const Vector3 &a,                                                  
     36                                                                 const Vector3 &b, 
     37                                                                 float *t, 
     38                                                                 bool *coplanar) const  
     39{ 
     40    const Vector3 v = b - a; // line from A to B 
     41    float dv = DotProd(v, mNormal); 
     42     
     43    if (signum(dv) == 0) 
     44        { 
     45                if (coplanar)  
     46                        (*coplanar) = true;      
     47 
     48                if (t)  
     49                        (*t) = 0; 
     50 
     51                return a; 
     52        } 
     53         
     54        if (coplanar)  
     55                (*coplanar) = false; 
     56 
     57    float u = - Distance(a) / dv; // TODO: could be done more efficiently 
     58     
     59        if (t)  
     60                (*t) = u; 
     61         
     62    return a + u * v; 
     63} 
     64 
     65 
     66int Plane3::Side(const Vector3 &v, const float threshold) const  
     67{ 
     68    return signum(Distance(v), threshold); 
     69} 
     70 
     71 
     72float Plane3::FindT(const Vector3 &a, const Vector3 &b) const  
     73{          
     74        const Vector3 v = b - a; // line from A to B 
     75        const float dv = DotProd(v, mNormal); 
     76     
     77        // does not intersect or coincident 
     78 
     79        if (signum(dv) == 0) 
     80                return 0; 
     81         
     82        return - Distance(a) / dv; // TODO: could be done more efficiently 
     83} 
Note: See TracChangeset for help on using the changeset viewer.