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

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

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

Author:
: Robert Lainé

Definition at line 3622 of file sailworker.cpp.

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

Referenced by CSailWorker(), IRCwidth(), Layout0(), LayoutMitre(), LayoutRadial(), LayoutTriRadial(), LayoutTwist(), LayoutVertical(), LayoutWing(), LuffLength(), SailLP(), and SailW().

{
    // 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 luff
    real hr0=0;  // its relative position on luff
    real d0=0;  //  its local depth of luff curve
    real hr1=0;  // its relative position on luff
    real d1=0;  //  its local depth of luff curve
    real hr2=0;  // its relative position on luff
    real d2=0;  //  its local depth of luff curve

    /* find point p0 at intersection of straight luff with ptv1 */
    CPoint3d p0 = ptv1.intersect(luff).getp();

    if (CVector3d(p0 - tack) * luffV <= 0.00001)
        p2=tack;  // intersection below tack
    else if (CVector3d(p0 - head) * luffV >= 0 )
        p2=head;  // intersection above head
    else if (fabs(luffR) <= 1)
        p2=p0;    // luff is straight
    else
    {  // intersection is on curved luff
        h0=CVector3d(p0 - tack).norm();
        hr0 = h0/(luffV.norm()+.000001); // relative height
        d0 = luffR * RoundP(hr0, luffRP); // local depth of luff curve


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

        d1=d0; // initialise

        for (j=1; j<4; j++)
        {
            p1 = p0 + CMatrix::rot3d(2, PI/2) * luffV.unit() * d1;
            // define a line parrallel to luff at distance d1
            CSubSpace parallel(p1, luffV.matrix(), GEOCPP_FROM_BASE);
            // point intersection of ptv1 with parrallel to luff
            p2 = ptv1.intersect(parallel).getp();
            dh2 = CVector3d(p2 - p0) * luffV.unit(); // projection on luff
            hr2 = (h0+dh2) / (luffV.norm()+.000001);
            if (hr2 <= 0)
                d2=0;
            else if (hr2 >= 1)
                d2=0;
            else
                d2 = luffR * RoundP(hr2, luffRP); // local depth of luff curve

            dh1 = dh2 * d1 / (2*d1-d2);
            hr1 = (h0+dh1) / (luffV.norm() +.000001);
            if (hr1 <= 0)
                d1=0;
            else if (hr2 >= 1)
                d1=0;
            else
                d1 = luffR * RoundP(hr1, luffRP); // local depth of luff curve
        } // end FOR loop

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


Generated by  Doxygen 1.6.0   Back to index