DXF: export the right supplementary angle.

Before this commit, e.g. a 120° angle could be exported as its
supplementary 60° angle but it would still say 120° in the label.

After this commit, the right angle is selected in DXF-based software.
Similarly, it roundtrips through SolveSpace correctly.
pull/4/merge
EvilSpirit 2016-05-07 16:30:26 +06:00 committed by whitequark
parent 11919bf0c1
commit ae60187322
1 changed files with 27 additions and 0 deletions

View File

@ -385,6 +385,33 @@ public:
&skew);
if(!skew) ref = pi.Plus(c->disp.offset);
Vector norm = da.Cross(db);
Vector dna = norm.Cross(da).WithMagnitude(1.0);
double thetaf = acos(da.DirectionCosineWith(db));
// Calculate median
Vector m = da.WithMagnitude(1.0).ScaledBy(cos(thetaf/2)).Plus(
dna.ScaledBy(sin(thetaf/2)));
Vector rm = ref.Minus(pi);
// Test which side we have to place an arc
if(m.Dot(rm) < 0) {
da = da.ScaledBy(-1); dna = dna.ScaledBy(-1);
db = db.ScaledBy(-1);
}
Vector bisect = da.WithMagnitude(1.0).ScaledBy(cos(thetaf / 2.0)).Plus(
dna.ScaledBy(sin(thetaf / 2.0)));
ref = pi.Plus(bisect.WithMagnitude(c->disp.offset.Magnitude()));
// Get lines agian to write exact line.
a0 = a->VectorGetStartPoint();
b0 = b->VectorGetStartPoint();
da = a->VectorGetNum();
db = b->VectorGetNum();
writeAngularDimension(
xfrm(a0), xfrm(a0.Plus(da)), xfrm(b0), xfrm(b0.Plus(db)), xfrm(ref),
xfrm(ref), c->Label(), c->GetStyle(), c->valA);