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

CPanel CPanel::develop ( enumDevelopAlign  align  )  const

This routine returns the development of the panel. The developed panel will be horizontal with its upper or lower edge aligned to X axis depending on parameter "align"=ALIGN_TOP or ALIGN_BOTTOM

establish origine at bottom point 0

establish baseline as (top point1 - bottom point1)

develop left side of panel by triangulation

develop body of panel by zig-zag triangulation

develop right side of panel

re-align panel with top or bottom edge along X axis

frame the developed panel to be X>0 and Y>0

Definition at line 234 of file sail.cpp.

References bottom, hasHems, left, CSide::nbpoints(), CVector::norm(), CSide::point, reframe(), right, CMatrix::rot3d(), rotate(), top, CVector3d::x(), and CVector3d::y().

{
    CPanel flatpanel;
    unsigned int npl= left.nbpoints();   // number of right/left points
    unsigned int npb= bottom.nbpoints(); // number of top/bottom points
    unsigned int i;
    real a=0, b=0, c=0; // sides of triangle
    real CC=0;  // angle opposite to side c of triangle
    CVector3d v;
    CPoint3d p1, p2, p3, p4;  // points for 2 triangular element of panel to be developed
    CPoint3d d3(0,0,0);  // point after development

    /** establish origine at bottom point 0 */
    flatpanel.bottom.point[0]= d3;

    /** establish baseline as (top point1 - bottom point1) */
    p1= bottom.point[1];
    p2= top.point[1];
    p3= bottom.point[0];
    a= CVector3d(p2-p1).norm(); // vertical side at point 1
    b= CVector3d(p3-p1).norm(); // lower side of triangle
    c= CVector3d(p2-p3).norm();
    CC = Atriangle(a,b,c);      // angle of bottom left corner = opposite to side a

    d3.x() =  b;
    flatpanel.bottom.point[1]= d3;

    // point at top of baseline
    d3 = flatpanel.bottom.point[0] + CMatrix::rot3d(2,CC) * CVector3d(1,0,0) * c;
    flatpanel.top.point[1]= d3;

    // set baseline vector
    v= CVector3d(flatpanel.bottom.point[1]-flatpanel.top.point[1]);

    /** develop left side of panel by triangulation */
    for (i=0; i< npl; i++)
    {
        p3= left.point[i];
        b= CVector3d(p3-p1).norm(); // lower side of triangle
        c= CVector3d(p3-p2).norm(); // upper side of triangle
        CC = Atriangle(c,a,b);      // angle of bottom corner = opposite to upper side
        // transpose corner of triangle in development plane
        d3 = flatpanel.bottom.point[1] + CMatrix::rot3d(2,-PI+CC) * v * (b/v.norm());
        flatpanel.left.point[i]= d3;
    } // end for

    // copy lower left point to bottom[0]
    flatpanel.bottom.point[0]= flatpanel.left.point[0];
    // copy upper left point to top[0]
    flatpanel.top.point[0]= flatpanel.left.point[npl-1];

    /** develop body of panel by zig-zag triangulation */
    // reset baseline vector for lower right point
    v= CVector3d(flatpanel.bottom.point[1]-flatpanel.top.point[1]);
    c= CVector3d(v).norm();

    for (i=1; i<npb-2; i++ )
    {
        // define the 4 points corners of 2 adjacent triangles
        p1= bottom.point[i];
        p2= top.point[i];
        p3= bottom.point[i+1];
        p4= top.point[i+1];

        // first triangle = lower right p1-p2-p3
        a= c;
        b= CVector3d(p3-p1).norm();
        c= CVector3d(p3-p2).norm();
        CC= Atriangle(c,b,a);
        // transpose corner of triangle in development plane
        d3= flatpanel.bottom.point[i] + CMatrix::rot3d(2,PI-CC)* v * (b/v.norm());
        flatpanel.bottom.point[i+1]= d3;

        // set baseline vector for upper right point
        v= CVector3d(flatpanel.top.point[i]-flatpanel.bottom.point[i+1]);

        // second triangle = upper right
        a= c;
        b= CVector3d(p4-p2).norm();
        c= CVector3d(p4-p3).norm();
        CC= Atriangle(c,b,a);
        // transpose corner of triangle in development plane
        d3= flatpanel.top.point[i] + CMatrix::rot3d(2,-PI+CC)* v * (b/v.norm());
        flatpanel.top.point[i+1]= d3;

        // set next baseline vector
        v= CVector3d(flatpanel.bottom.point[i+1]-flatpanel.top.point[i+1]);
    } // end for

    /** develop right side of panel */
    a= c; // baseline on last 2 points
    for (i=0; i< npl; i++)
    {
        p1= right.point[i];
        b= CVector3d(p3-p1).norm(); // lower side of triangle
        c= CVector3d(p4-p1).norm(); // upper side of triangle
        CC = Atriangle(c,a,b);      // angle of bottom corner = opposite to upper side
        // transpose corner of triangle in development plane
        d3 = flatpanel.bottom.point[npb-2] +CMatrix::rot3d(2,PI-CC)* v *(b/v.norm());
        flatpanel.right.point[i]= d3;
    }// end for
    // copy lower right point to bottom end
    flatpanel.bottom.point[npb-1]= flatpanel.right.point[0];
    // copy upper right point to top end
    flatpanel.top.point[npb-1]= flatpanel.right.point[npl-1];

    /** re-align panel with top or bottom edge along X axis */
    CC = 0;
    if (align==ALIGN_TOP)
    { // align on top edge
        p1 = flatpanel.top.point[0];
        p2 = flatpanel.top.point[npb-1];
        CC = atan2( (p2.y()-p1.y()) , (p2.x()-p1.x()) );
    }
    else
    { // align on bottom edge
        p1 = flatpanel.bottom.point[0];
        p2 = flatpanel.bottom.point[npb-1];
        CC = atan2( (p2.y()-p1.y()) , (p2.x()-p1.x()) );
    }
    // align panel
    flatpanel = flatpanel.rotate(CPoint3d(0,0,0), CMatrix::rot3d(2,-CC) );

    flatpanel.hasHems = false;

    /** frame the developed panel to be X>0 and Y>0 */
    flatpanel = flatpanel.reframe(LOW_LEFT);

    // the following 4 lines are for debugging purpose only
    //   p1 = flatpanel.bottom.point[0];
    //   p2 = flatpanel.bottom.point[npb-1];
    //   p3 = flatpanel.top.point[0];
    //   p4 = flatpanel.top.point[npb-1];

    return flatpanel;
}


Generated by  Doxygen 1.6.0   Back to index