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

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

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

Author:
Robert Lainé

a position on gaff

Definition at line 3458 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().

{
    // 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 gaff
    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 gaff with ptv1 */
    CPoint3d p0 = ptv1.intersect(gaff).getp();

    if (CVector3d(p0 - head) * gaffV <= 0.00001)
        p2=head;  // intersection left of gaff
    else if (CVector3d(p0 - peak) * gaffV >= 0 )
        p2=peak;  // intersection above peak
    else if (fabs(gaffR) < 1)
        p2=p0;    // gaff is straight
    else
    {  // intersection is on curved gaff
        h0=CVector3d(p0 - head).norm();
        hr0 = h0/(gaffV.norm() +.00001); // relative height
        d0 = gaffR * RoundP(hr0, gaffRP); // local depth of gaff curve

        /* loop to converge on real gaff 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) * gaffV.unit() * d1;
            // define a line parrallel to gaff at distance d1
            CSubSpace parallel(p1, gaffV.matrix(),GEOCPP_FROM_BASE);
            // point intersection of ptv1 with parrallel
            p2 = ptv1.intersect(parallel).getp();
            dh2 = CVector3d(p2 - p0) * gaffV.unit(); // projection on gaff
            hr2 = (h0+dh2) / (gaffV.norm() +.00001);
            if (hr2 <= 0)
                d2=0;
            else if (hr2 >= 1)
                d2=0;
            else
                d2 = gaffR * RoundP(hr2, gaffRP); // local depth of gaff curve

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

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


Generated by  Doxygen 1.6.0   Back to index