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

CPoint3d CSailWorker::Zpoint ( const CPoint3d p1  )  [protected]

Routine used for computing the Z of any point of the sail. Return a CPoint3D p2 which is p1 point with its Z modified

Author:
Robert Lainé

Definition at line 3729 of file sailworker.cpp.

References AftIntersect(), FwdIntersect(), CSailMould::interpol(), CSailDef::mould, CSailDef::sheetDeg, CSailDef::twistDeg, CVector3d::x(), CVector3d::y(), CVector3d::z(), and CProfile::z().

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

{
    /* QString txt = "input Zpt -------------   x=" + QString::number (p1.x() ) + "  y=" + QString::number (p1.y() ) + "  z="+ QString::number (p1.z() );
       qDebug ( txt );
    */
    CPoint3d p2 = p1;            // will be the returned point with Z added

    real x=0,  z=0, twist=0, pivotX=0, pos=0;
    CPoint3d pFwd = FwdIntersect(p1);   // forward end of the cord
    CPoint3d pAft = AftIntersect(p1);    // rear end of the cord

    /* computing local cord of the profile */
    real cord = CVector3d(pAft-pFwd).norm();

    /* computing Z from normalised position on profile */
    if ( cord < 1 )   // to avoid division by cord = zero
    {
         pos = 0 ;
         z = 0;
    }
    else   // position on profile
    {
        pos = (CVector3d(p1-pFwd).norm()) / cord;
        /* computing the relative height on the sail */
        real h1 = (p1.y() - tack.y()) / (peak.y() - tack.y()+.0001);  // for mould
        /* computing actual Z  including twist and sheeting angle
        *  kluff, kleech, depth coefficient used in z1=f(pos, h1) of the
        *  sailmould are interpolated between the respective profile[0..2].
        *  The position of profile[1] is driven by vertpos which is
        *  the vertical position of the middle profile entered in the
        *  left vertical pane of formmouldbase.
        */
        z = cord * mould.interpol(h1).z(pos);
    }

    /* computing the twist from the relative height on straight leech */
    real h2 = (p1.y() - clew.y()) / (peak.y() - clew.y()+.0001);  // for twist
        // h2 range is limited to 0..1
        if (h2 >= 1)
            h2 = 1;
        else if (h2 <= 0)
            h2 = 0;

    twist = ( h2 * twistDeg  + sheetDeg ) * PI / 180;

    if ( p1.y() >= head.y() )   // on gaff
        pivotX = head.x();
    else if ( p1.y() <= tack.y() )   // below tack
        pivotX = tack.x();
    else   // on luff
        pivotX = pFwd.x();

    x = p1.x() - pivotX;
    /* debugging
    if (p1.x() <= 3520 && p1.y()<=410)
    {   QString txt = "input pt x=" + QString::number (p1.x() ) + "  pt y=" + QString::number (p1.y() ) + "  pt z="+ QString::number (p1.z() )+ " - pivotX="+QString::number(pivotX)+"  x="+QString::number(x) + "  z="+QString::number(z);
        qDebug ( txt );
    }
   */

    /* applying the twist by rotating the profile around pivotX */
    p2.x() = pivotX + x * cos(twist) - z * sin(twist);
    p2.z() = x * sin(twist) + z * cos(twist);

    return p2;
} /////////////// Zpoint ///////////////////////////////////////////////


Generated by  Doxygen 1.6.0   Back to index