GCS/Sketcher: Add equal length line constraint using the new single constraint

This commit is contained in:
Abdullah Tahiri
2021-01-19 19:55:45 +01:00
committed by abdullahtahiriyo
parent 5609269ca8
commit 186f5a4c19
3 changed files with 9 additions and 14 deletions

View File

@@ -2675,16 +2675,9 @@ int Sketch::addEqualConstraint(int geoId1, int geoId2)
Geoms[geoId2].type == Line) {
GCS::Line &l1 = Lines[Geoms[geoId1].index];
GCS::Line &l2 = Lines[Geoms[geoId2].index];
double dx1 = (*l1.p2.x - *l1.p1.x);
double dy1 = (*l1.p2.y - *l1.p1.y);
double dx2 = (*l2.p2.x - *l2.p1.x);
double dy2 = (*l2.p2.y - *l2.p1.y);
double value = (sqrt(dx1*dx1+dy1*dy1)+sqrt(dx2*dx2+dy2*dy2))/2;
// add the parameter for the common length (this is added to Parameters, not FixParameters)
Parameters.push_back(new double(value));
double *length = Parameters[Parameters.size()-1];
int tag = ++ConstraintsCounter;
GCSsys.addConstraintEqualLength(l1, l2, length, tag);
GCSsys.addConstraintEqualLength(l1, l2, tag);
return ConstraintsCounter;
}