Fixed issue #578 (CIF writer issue with arbitrary angle) (#581)

* Fixed isse #578 (CIF writer issue with arbitrary angle)

* Added missing files.
This commit is contained in:
Matthias Köfferlein
2020-06-05 10:57:14 +02:00
committed by GitHub
parent 2d0a9418f9
commit 8db1e3577f
4 changed files with 35 additions and 16 deletions
@@ -165,23 +165,18 @@ CIFWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::SaveLa
}
double a = t.angle();
while (a < 0) {
a += 360.0;
}
double ya = 0.0, xa = 0.0;
if (a < 45 || a > 315) {
xa = 1.0;
ya = tan(a / 180.0 * M_PI);
} else if (a < 135) {
xa = 1.0 / tan(a / 180.0 * M_PI);
ya = 1.0;
} else if (a < 225) {
xa = -1.0;
ya = tan(a / 180.0 * M_PI);
double xa = cos(a / 180.0 * M_PI);
double ya = sin(a / 180.0 * M_PI);
// normalize xa or ya whichever is better
double n;
if (fabs (xa) >= M_SQRT1_2) {
n = 1.0 / fabs (xa);
} else {
xa = 1.0 / tan(a / 180.0 * M_PI);
ya = -1.0;
}
n = 1.0 / fabs (ya);
}
xa *= n;
ya *= n;
// TODO: that can be done smarter ...
for (int n = 0; n < 20 && (fabs (xa - floor (0.5 + xa)) > 1e-3 || fabs (ya - floor (0.5 + ya)) > 1e-3); ++n) {
@@ -200,3 +200,9 @@ TEST(rot_instances)
{
run_test (_this, tl::testsrc (), "issue_568.cif", "issue_568_au.gds");
}
// Issue #578
TEST(rot_instances2)
{
run_test (_this, tl::testsrc (), "issue_578.cif", "issue_578_au.gds");
}