Logo Search packages:      
Sourcecode: sailcut version File versions  Download package

CPoint3d CSailWorker::FootIntersect ( const CPoint3d pt1,
const CVector3d v1 
) [protected]

Routine used for computing the real position of foot points. Return a 3d point which is the forward intersection of the vector v1 passing by pt1 point inside sail area with the foot curve

Author:
Robert Lainé

a position on foot

Definition at line 3365 of file sailworker.cpp.

References CSubSpace::getp(), CSubSpace::intersect(), CVector::matrix(), CVector::norm(), CMatrix::rot3d(), and CVector::unit().

Referenced by Layout0(), LayoutMitre(), LayoutRadial(), LayoutTriRadial(), LayoutTwist(), LayoutVertical(), and LayoutWing().

{
    // QString txt;
    // txt = "input pt -------------   x=" + QString::number (pt1.x() ) + "  y=" + QString::number (pt1.y() ) + "  z="+ QString::number (pt1.z() );
    // qDebug ( txt );
   // txt = "vector intersection   x=" + QString::number (v1.x() ) + "  y=" + QString::number (v1.y() ) + "  z="+ QString::number (v1.z() );
    //qDebug ( txt );
    // real x=0, y=0, z=0; // for debugging only
    CPoint3d p2=pt1;

    /* useful straight lines */
    CSubSpace ptv1(pt1,CVector3d(v1).matrix(),GEOCPP_FROM_BASE);

    real h0=0;  /// a position on foot
    real hr0=0;  // its relative position
    real d0=0;   // its local depth of curve
    real hr1=0;  // its relative position
    real d1=0;   // its local depth
    real hr2=0;  // its relative position
    real d2=0;   // its local depth

    /* find point p0 at intersection of straight foot with ptv1 */
    CPoint3d p0 = ptv1.intersect(foot).getp();
    //txt = "foot intersection p0  x=" + QString::number (p0.x() ) + "  y=" + QString::number (p0.y() ) + "  z="+ QString::number (p0.z() );
    //qDebug ( txt );

    if (CVector3d(p0-tack)*footV <= 0.0001)
        p2=tack;  // intersection left of tack
    else if (CVector3d(p0-clew)*footV >= 0 )
        p2=clew;  // intersection right of clew
    else if (fabs(footR) < 1)
        p2=p0;    // foot is straight
    else
    {  // intersection is on curved foot
        h0=CVector3d(p0-tack).norm();
        hr0 = h0/(footL+.00001); // relative height
        d0 = footR * RoundP(hr0,footRP); // local depth of foot curve

        /* loop to converge on real foot point */
        unsigned int j=1;
        real  dh1=0, dh2=0;
        CPoint3d p1=p0;

        d1=d0; // initialise

        for (j=1; j<3; j++)
        { /* p1 is p0 moved on curve */
            p1 = p0 + CMatrix::rot3d(2,-PI/2)*footV.unit()*d1;
            // define a line parrallel to foot at distance d1
            CSubSpace parallel(p1, footV.matrix(),GEOCPP_FROM_BASE);
            // point intersection of ptv1 with parrallel
            p2 = ptv1.intersect(parallel).getp();
            dh2 = CVector3d(p2-p0)*footV.unit(); // projection on foot
            hr2 = (h0+dh2)/(footL+.00001);
            if (hr2 <= 0)
                d2=0;
            else if (hr2 >= 1)
                d2=0;
            else
                d2 = footR * RoundP(hr2,footRP); // local depth of foot curve

            dh1 = dh2 * d1/(2*d1-d2);
            hr1 = (h0+dh1)/(footL+.00001);
            if (hr1 <= 0)
                d1=0;
            else if (hr1 >= 1)
                d1=0;
            else
                d1 = footR * RoundP(hr1,footRP); // local depth of foot curve
        } // end FOR loop

        /* final convergence on mean point */
        d1 = (d1 + d2)/2;
        p1 = p0 + CMatrix::rot3d(2, -PI/2)*footV.unit() * d1;
        // define a line parrallel to leech at distance d1
        CSubSpace parallel(p1, footV.matrix(),GEOCPP_FROM_BASE);
        // point intersection of ptv1 with parrallel
        p2 = ptv1.intersect(parallel).getp();
    } // end IF ELSE

      //  txt = "foot intersection p2  x=" + QString::number (p2.x() ) + "  y=" + QString::number (p2.y() ) + "  z="+ QString::number (p2.z() );
      //  qDebug ( txt );

    return p2;
} /////////////// FootIntersect ///////////////////////////////////////


Generated by  Doxygen 1.6.0   Back to index