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

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

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

Author:
Robert Lainé

a position on leech

Definition at line 3540 of file sailworker.cpp.

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

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

{
    // real x=0, y=0, z=0; // for debugging only
    CPoint3d p2=pt1;

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

    real h0=0;  /// a position on leech
    real hr0=0;  // its relative position on leech
    real d0=0;   // its local depth of leech 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 leech with ptv1 */
    CPoint3d p0 = ptv1.intersect(leech).getp();

    if (CVector3d(p0 - clew) * leechV <= 0.00001)
        p2=clew;  // intersection below clew
    else if (CVector3d(p0 - peak) * leechV >= 0 )
        p2=peak;  // intersection above peak
    else if (fabs(leechR) < 1)
        p2=p0;    // leech is straight
    else
    {  // intersection is on curved leech
        h0=CVector3d(p0 - clew).norm();
        hr0 = h0 / (leechV.norm()+.00001); // relative height
        d0 = leechR * RoundP(hr0, leechRP); // local depth of leech curve

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

        d1=d0; // initialise

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

            dh1 = dh2 * d1 / (2*d1 - d2);
            hr1 = (h0+dh1) / (leechV.norm()+.00001);
            if (hr1 <= 0)
                d1=0;
            else if (hr2 >= 1)
                d1=0;
            else
                d1 = leechR * RoundP(hr1, leechRP); // local depth of leech curve
        } // end FOR loop

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


Generated by  Doxygen 1.6.0   Back to index