computes the intersection between 1) the infinite line passing through the origin with direction +-unitDir; 2) the infinite line containing the segment bc, returning in \param a the intersection position on that line. \return false if the segment bc is parallel to unitDir
| 37 | /// 2) the infinite line containing the segment bc, returning in \param a the intersection position on that line. |
| 38 | /// \return false if the segment bc is parallel to unitDir |
| 39 | static bool computeLineLineCross( const Vector3f & b, const Vector3f & c, const Vector3f & unitDir, float & a ) |
| 40 | { |
| 41 | const auto d = c - b; |
| 42 | // gort is a vector in the triangle plane orthogonal to grad |
| 43 | const auto gort = d - dot( d, unitDir ) * unitDir; |
| 44 | //const auto god = dot( d, d ) - sqr( dot( d, unitDir ) ); |
| 45 | const auto god = dot( gort, d ); |
| 46 | if ( god <= 0 ) |
| 47 | return false; // segment bc is parallel to unitDir |
| 48 | const auto gob = -dot( gort, b ); |
| 49 | a = gob / god; |
| 50 | return true; |
| 51 | } |
| 52 | |
| 53 | /// given triangle with scalar field increasing in the direction \param unitDir; |
| 54 | /// returns true if the field increases inside the triangle from the edge 01 |
no test coverage detected