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

CSailWorker::CSailWorker ( const CSailDef s  ) 

The constructor does some preliminary calculations to set internal variables.

VC++ 6 pre-SP3 bug here if we pass the result of sqrt directly see : MS knowledgebase 217164)

Definition at line 31 of file sailworker.cpp.

References LuffIntersect(), CVector::matrix(), CMatrix::rot3d(), CSailDef::sailType, CVector::unit(), CVector3d::x(), and CVector3d::y().

                                          : CSailDef(s)
{
    /* first compute the coordinates of the corner of the sail */
    CVector3d v, v1;
    real x=0, headstay=0;

    /* computing the coordinates of the 4 corners of the sail */
    switch (sailType )
    {
    case JIB:
        x= tackY * foreI / foreJ;
        headstay= sqrt(foreI * foreI + foreJ * foreJ);
        rake= foreJ * luffL / headstay;
        tack = CPoint3d(x, tackY,0);
        //gaffL=1;
        gaffR=0;
        gaffRP=50;
        gaffDeg=atan2(foreI, foreJ) * 180/PI -10;
        break;
    default:
        tack = CPoint3d( tackX, tackY, 0 );
        break;
    }

    /// VC++ 6 pre-SP3 bug here if we pass the result of sqrt directly
    /// see : MS knowledgebase 217164)
    real stupid_hack = sqrt(luffL*luffL - rake*rake);
    head = tack + CVector3d(rake, stupid_hack, 0);

    v = CVector3d(0, gaffL, 0);  // initial vector gaff set on vertical
    peak = head + CMatrix::rot3d(2, -asin(rake / luffL) - gaffDeg * PI / 180) * v;

    /* computing triangle tack-peak-clew */
    real aa, b, bb;
    bb= atan2(peak.y()-tack.y() , peak.x()-tack.x() );
    b = CVector3d(peak - tack).norm();
    aa = Atriangle(leechL, b, footL);

    v1 = CVector3d(footL, 0, 0);  // initial foot vector set on horizontal
    if (sailType==WING)
        clew = tack + v1;
    else
        clew = tack + CMatrix::rot3d(2, bb-aa) * v1;
    ////// end of computation of corners of the sail

    /* define useful vectors of edges */
    footV = CVector3d(clew-tack);
    gaffV = CVector3d(peak-head);
    leechV = CVector3d(peak-clew);
    luffV = CVector3d(head-tack);

    /* define usefull vector mitre */
    mitreV = CVector3d(tack-clew).unit() +leechV.unit();

    /* define the unitary vectors perpendicular to the edges */
    footVP = CMatrix::rot3d(2, PI/2) * footV.unit();
    gaffVP = CMatrix::rot3d(2, PI/2) * gaffV.unit();
    leechVP = CMatrix::rot3d(2, PI/2) * leechV.unit();
    luffVP =CMatrix::rot3d(2, PI/2) * luffV.unit();

    /* define useful straight lines */
    foot = CSubSpace(tack, footV.matrix(), GEOCPP_FROM_BASE);
    gaff = CSubSpace(head, gaffV.matrix(), GEOCPP_FROM_BASE);
    leech = CSubSpace(clew, leechV.matrix(), GEOCPP_FROM_BASE);
    luff = CSubSpace(tack, luffV.matrix(), GEOCPP_FROM_BASE);
    mitre = CSubSpace(clew, mitreV.matrix(),GEOCPP_FROM_BASE);

    /* define point at intersection of mitre and luff */
    mitrePt = LuffIntersect (clew , mitreV);
    ///
}


Generated by  Doxygen 1.6.0   Back to index