Skip to content

Commit

Permalink
GCS: Extension of ConstraintEqual to allow for a proportionality factor
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo authored and wwmayer committed Jul 29, 2018
1 parent 4ae2692 commit dcdb664
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/Mod/Sketcher/App/planegcs/Constraints.cpp
Expand Up @@ -97,8 +97,9 @@ int Constraint::findParamInPvec(double *param)
}

// Equal
ConstraintEqual::ConstraintEqual(double *p1, double *p2)
ConstraintEqual::ConstraintEqual(double *p1, double *p2, double p1p2ratio)
{
ratio = p1p2ratio;
pvec.push_back(p1);
pvec.push_back(p2);
origpvec = pvec;
Expand All @@ -117,7 +118,7 @@ void ConstraintEqual::rescale(double coef)

double ConstraintEqual::error()
{
return scale * (*param1() - *param2());
return scale * (*param1() - ratio *(*param2()));
}

double ConstraintEqual::grad(double *param)
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/Sketcher/App/planegcs/Constraints.h
Expand Up @@ -131,10 +131,11 @@ namespace GCS
class ConstraintEqual : public Constraint
{
private:
double ratio;
inline double* param1() { return pvec[0]; }
inline double* param2() { return pvec[1]; }
public:
ConstraintEqual(double *p1, double *p2);
ConstraintEqual(double *p1, double *p2, double p1p2ratio=1.0);
virtual ConstraintType getTypeId();
virtual void rescale(double coef=1.);
virtual double error();
Expand Down

0 comments on commit dcdb664

Please sign in to comment.