asymmetric layout

Eddie Wyatt edw at IUS1.CS.CMU.EDU
Thu Mar 17 02:26:51 AEST 1988


  Way back whenever, someone posted a list of thou shall and thou shall not.
One item on that list was asymmetric layout of assignment.  Its use was
mainly to help the reader to distinguish assignment for equality
testing.   I've adopted a convention related to that topic
that others may find useful and thought I'd share it with all of
you.  (I'm such a nice guy :-))

 In code segments that contain a lot of assigments, align the equal
signs.  Example :


    cosyaw = cos(rotate[YYAW]);
    sinyaw = sin(rotate[YYAW]);

    cosroll = cos(rotate[RROLL]);
    sinroll = sin(rotate[RROLL]);

    cospitch = cos(rotate[PPITCH]);
    sinpitch = sin(rotate[PPITCH]);

    /* x - axis */
    yp = point[YY]*cosroll - point[ZZ]*sinroll;
    zp = point[YY]*sinroll + point[ZZ]*cosroll;

    point[YY] = yp;
    point[ZZ] = zp;

    /* y - axis */
    zp = point[ZZ]*cospitch - point[XX]*sinpitch;
    xp = point[ZZ]*sinpitch + point[XX]*cospitch;

    point[XX] = xp;
    point[ZZ] = zp;

    /* z - axis */
    xp = point[XX]*cosyaw - point[YY]*sinyaw;
    yp = point[XX]*sinyaw + point[YY]*cosyaw;
 
    point[XX] = xp;
    point[YY] = yp;

    
becomes:

    cosyaw              = cos(rotate[YYAW]);
    sinyaw              = sin(rotate[YYAW]);

    cosroll             = cos(rotate[RROLL]);
    sinroll             = sin(rotate[RROLL]);

    cospitch            = cos(rotate[PPITCH]);
    sinpitch            = sin(rotate[PPITCH]);

    /* x - axis */
    yp                  = point[YY]*cosroll - point[ZZ]*sinroll;
    zp                  = point[YY]*sinroll + point[ZZ]*cosroll;

    point[YY]           = yp;
    point[ZZ]           = zp;

    /* y - axis */
    zp                  = point[ZZ]*cospitch - point[XX]*sinpitch;
    xp                  = point[ZZ]*sinpitch + point[XX]*cospitch;

    point[XX]           = xp;
    point[ZZ]           = zp;

    /* z - axis */
    xp                  = point[XX]*cosyaw - point[YY]*sinyaw;
    yp                  = point[XX]*sinyaw + point[YY]*cosyaw;
 
    point[XX]           = xp;
    point[YY]           = yp;

Easier to read no?
-- 

Eddie Wyatt 				e-mail: edw at ius1.cs.cmu.edu



More information about the Comp.lang.c mailing list