Changeset 76cf7f1 in git for src/export.cc


Ignore:
Timestamp:
04/09/19 02:27:11 (7 weeks ago)
Author:
Olly Betts <olly@…>
Branches:
master
Children:
7061908
Parents:
6363690
Message:

Fix rotated exports

When exporting to a format where we support rotation in the horizontal
plane (such as SVG), the rotation was incorrectly applied to cross
section data (except for the default rotation of zero).

Fixes #108, reported by Richard Knapp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/export.cc

    r6363690 r76cf7f1  
    33 */
    44
    5 /* Copyright (C) 1994-2004,2005,2006,2008,2010,2011,2012,2013,2014,2015,2016,2018 Olly Betts
     5/* Copyright (C) 1994-2004,2005,2006,2008,2010,2011,2012,2013,2014,2015,2016,2018,2019 Olly Betts
    66 * Copyright (C) 2004 John Pybus (SVG Output code)
    77 *
     
    376376   fprintf(fh, "0\nLINE\n");
    377377   fprintf(fh, "8\nCross-sections\n"); /* Layer */
    378    fprintf(fh, "10\n%6.2f\n", p->x + c * d1);
    379    fprintf(fh, "20\n%6.2f\n", p->y + s * d1);
     378   fprintf(fh, "10\n%6.2f\n", p->x + s * d1);
     379   fprintf(fh, "20\n%6.2f\n", p->y + c * d1);
    380380   fprintf(fh, "30\n%6.2f\n", p->z);
    381    fprintf(fh, "11\n%6.2f\n", p->x - c * d2);
    382    fprintf(fh, "21\n%6.2f\n", p->y - s * d2);
     381   fprintf(fh, "11\n%6.2f\n", p->x - s * d2);
     382   fprintf(fh, "21\n%6.2f\n", p->y - c * d2);
    383383   fprintf(fh, "31\n%6.2f\n", p->z);
    384384}
     
    397397   fprintf(fh, "0\nVERTEX\n");
    398398   fprintf(fh, "8\nWalls\n"); /* Layer */
    399    fprintf(fh, "10\n%6.2f\n", p->x + c * d);
    400    fprintf(fh, "20\n%6.2f\n", p->y + s * d);
     399   fprintf(fh, "10\n%6.2f\n", p->x + s * d);
     400   fprintf(fh, "20\n%6.2f\n", p->y + c * d);
    401401   fprintf(fh, "30\n%6.2f\n", p->z);
    402402}
     
    409409   double s = sin(rad(angle));
    410410   double c = cos(rad(angle));
    411    double x1 = p->x + c * d1;
    412    double y1 = p->y + s * d1;
    413    double x2 = p->x - c * d2;
    414    double y2 = p->y - s * d2;
     411   double x1 = p->x + s * d1;
     412   double y1 = p->y + c * d1;
     413   double x2 = p->x - s * d2;
     414   double y2 = p->y - c * d2;
    415415   if (*pending) {
    416416       fputs(pending, fh);
     
    744744   double c = cos(rad(angle));
    745745   fprintf(fh, "<path d=\"M%.3f %.3fL%.3f %.3f\"/>\n",
    746            (p->x + c * d1) * factor, (p->y + s * d1) * -factor,
    747            (p->x - c * d2) * factor, (p->y - s * d2) * -factor);
     746           (p->x + s * d1) * factor, (p->y + c * d1) * -factor,
     747           (p->x - s * d2) * factor, (p->y - c * d2) * -factor);
    748748}
    749749
     
    759759   double s = sin(rad(angle));
    760760   double c = cos(rad(angle));
    761    fprintf(fh, "%.3f %.3f", (p->x + c * d) * factor, (p->y + s * d) * -factor);
     761   fprintf(fh, "%.3f %.3f", (p->x + s * d) * factor, (p->y + c * d) * -factor);
    762762}
    763763
     
    767767   double s = sin(rad(angle));
    768768   double c = cos(rad(angle));
    769    double x1 = (p->x + c * d1) * factor;
    770    double y1 = (p->y + s * d1) * -factor;
    771    double x2 = (p->x - c * d2) * factor;
    772    double y2 = (p->y - s * d2) * -factor;
     769   double x1 = (p->x + s * d1) * factor;
     770   double y1 = (p->y + c * d1) * -factor;
     771   double x2 = (p->x - s * d2) * factor;
     772   double y2 = (p->y - c * d2) * -factor;
    773773   if (*pending) {
    774774       fputs(pending, fh);
     
    12331233    double c = cos(rad(angle));
    12341234    fprintf(fh, "%.2f %.2f M %.2f %.2f R\n",
    1235             p->x - c * d2, p->y - s * d2,
    1236             c * (d1 + d2), s * (d1 + d2));
     1235            p->x - s * d2, p->y - c * d2,
     1236            s * (d1 + d2), c * (d1 + d2));
    12371237}
    12381238
     
    12421242    double s = sin(rad(angle));
    12431243    double c = cos(rad(angle));
    1244     fprintf(fh, "%.2f %.2f %c\n", p->x + c * d, p->y + s * d, first ? 'M' : 'L');
     1244    fprintf(fh, "%.2f %.2f %c\n", p->x + s * d, p->y + c * d, first ? 'M' : 'L');
    12451245    first = false;
    12461246}
     
    12511251    double s = sin(rad(angle));
    12521252    double c = cos(rad(angle));
    1253     double x1 = p->x + c * d1;
    1254     double y1 = p->y + s * d1;
    1255     double x2 = p->x - c * d2;
    1256     double y2 = p->y - s * d2;
     1253    double x1 = p->x + s * d1;
     1254    double y1 = p->y + c * d1;
     1255    double x2 = p->x - s * d2;
     1256    double y2 = p->y - c * d2;
    12571257    fprintf(fh, "%.2f %.2f %c\n", x1, y1, first ? 'P' : 'L');
    12581258    first = false;
     
    16111611                  } else {
    16121612                      // Should only be enabled in plan or elevation mode.
    1613                       double angle = pan + xs.get_right_bearing();
     1613                      double angle = xs.get_right_bearing() - pan;
    16141614                      if (pass_mask & XSECT)
    16151615                          filt->xsect(&p, angle + 180, xs.GetL(), xs.GetR());
Note: See TracChangeset for help on using the changeset viewer.