1 #include <SketchSolver_ConstraintAngle.h>
5 void SketchSolver_ConstraintAngle::getAttributes(
6 double& theValue, std::vector<Slvs_hEntity>& theAttributes)
8 SketchSolver_Constraint::getAttributes(theValue, theAttributes);
14 void SketchSolver_ConstraintAngle::adjustConstraint()
16 Slvs_Constraint aConstraint = myStorage->getConstraint(mySlvsConstraints.front());
18 double aLineDir[2][2] = { {0.0, 0.0}, {0.0, 0.0} };
19 Slvs_hEntity anEnt[2] = {aConstraint.entityA, aConstraint.entityB};
20 for (int i = 0; i < 2; i++) {
21 const Slvs_Entity& aLine = myStorage->getEntity(anEnt[i]);
23 for (int j = 0; j < 2; j++, aCoef += 2.0) {
24 const Slvs_Entity& aPoint = myStorage->getEntity(aLine.point[j]);
25 for (int k = 0; k < 2; k++)
26 aLineDir[i][k] += aCoef * myStorage->getParameter(aPoint.param[k]).val;
29 double aDot = aLineDir[0][0] * aLineDir[1][0] + aLineDir[0][1] * aLineDir[1][1];
31 aConstraint.other = aDot * (90.0 - fabs(aConstraint.valA)) < 0.0;
32 if ((90.0 - fabs(aConstraint.valA)) * (90.0 - fabs(myAngle)) < 0.0)
33 aConstraint.other = !aConstraint.other;
34 myAngle = aConstraint.valA;
35 myStorage->updateConstraint(aConstraint);