@@ -13,7 +13,7 @@ import Linear.Constraint.Generic.Types
1313 ( GenericConstraint (.. )
1414 )
1515import Linear.Constraint.Simple.Types (SimpleConstraint )
16- import Linear.Constraint.Types (Constraint )
16+ import Linear.Constraint.Types (Constraint ( .. ) )
1717import Linear.Expr.Types (Expr (.. ), ExprVarsOnly (.. ))
1818import Linear.Expr.Util
1919 ( exprToExprVarsOnly
@@ -37,15 +37,15 @@ substVarSimpleConstraintExpr ::
3737substVarSimpleConstraintExpr var varReplacement (a :<= b) =
3838 let newExpr = substVarExpr var varReplacement (exprVarsOnlyToExpr a)
3939 newConstraint = newExpr :<= Expr [ConstTerm b]
40- in constraintToSimpleConstraint newConstraint
40+ in constraintToSimpleConstraint $ Constraint newConstraint
4141substVarSimpleConstraintExpr var varReplacement (a :>= b) =
4242 let newExpr = substVarExpr var varReplacement (exprVarsOnlyToExpr a)
4343 newConstraint = newExpr :>= Expr [ConstTerm b]
44- in constraintToSimpleConstraint newConstraint
44+ in constraintToSimpleConstraint $ Constraint newConstraint
4545substVarSimpleConstraintExpr var varReplacement (a :== b) =
4646 let newExpr = substVarExpr var varReplacement (exprVarsOnlyToExpr a)
4747 newConstraint = newExpr :== Expr [ConstTerm b]
48- in constraintToSimpleConstraint newConstraint
48+ in constraintToSimpleConstraint $ Constraint newConstraint
4949
5050substVarSimpleConstraint ::
5151 Var -> ExprVarsOnly -> SimpleConstraint -> SimpleConstraint
@@ -56,9 +56,9 @@ substVarSimpleConstraint var varReplacement (a :== b) = substVarExprVarsOnly var
5656constraintToSimpleConstraint :: Constraint -> SimpleConstraint
5757constraintToSimpleConstraint constraint =
5858 case constraint of
59- (a :<= b) -> uncurry (:<=) (calcLhsRhs a b)
60- (a :>= b) -> uncurry (:>=) (calcLhsRhs a b)
61- (a :== b) -> uncurry (:==) (calcLhsRhs a b)
59+ Constraint (a :<= b) -> uncurry (:<=) (calcLhsRhs a b)
60+ Constraint (a :>= b) -> uncurry (:>=) (calcLhsRhs a b)
61+ Constraint (a :== b) -> uncurry (:==) (calcLhsRhs a b)
6262 where
6363 calcLhsRhs a b = (lhs, rhs)
6464 where
@@ -76,48 +76,6 @@ constraintToSimpleConstraint constraint =
7676 error $
7777 " constraintToSimpleConstraint: lhs is not ExprVarsOnly. Details: " <> err
7878
79- -- normalize simple constraints by moving all constants to the right
80- -- normalizeSimpleConstraint :: SimpleConstraint -> SimpleConstraint
81- -- normalizeSimpleConstraint (expr :<= num) =
82- -- let exprList = exprToList expr
83-
84- -- isConstTerm (ConstTerm _) = True
85- -- isConstTerm _ = False
86-
87- -- (sumExprConstTerms, nonConstTerms) = L.partition isConstTerm exprList
88-
89- -- constTermsVal = sum . map (\case (ConstTerm c) -> c; _ -> 0) $ sumExprConstTerms
90-
91- -- newExpr = listToExpr nonConstTerms
92- -- newNum = num - constTermsVal
93- -- in newExpr :<= newNum
94- -- normalizeSimpleConstraint (expr :>= num) =
95- -- let exprList = exprToList expr
96-
97- -- isConstTerm (ConstTerm _) = True
98- -- isConstTerm _ = False
99-
100- -- (sumExprConstTerms, nonConstTerms) = L.partition isConstTerm exprList
101-
102- -- constTermsVal = sum . map (\case (ConstTerm c) -> c; _ -> 0) $ sumExprConstTerms
103-
104- -- newExpr = listToExpr nonConstTerms
105- -- newNum = num - constTermsVal
106- -- in newExpr :>= newNum
107- -- normalizeSimpleConstraint (expr :== num) =
108- -- let exprList = exprToList expr
109-
110- -- isConstTerm (ConstTerm _) = True
111- -- isConstTerm _ = False
112-
113- -- (sumExprConstTerms, nonConstTerms) = L.partition isConstTerm exprList
114-
115- -- constTermsVal = sum . map (\case (ConstTerm c) -> c; _ -> 0) $ sumExprConstTerms
116-
117- -- newExpr = listToExpr nonConstTerms
118- -- newNum = num - constTermsVal
119- -- in newExpr :== newNum
120-
12179-- | Simplify coeff constraints by dividing the coefficient from both sides
12280simplifyCoeff :: SimpleConstraint -> SimpleConstraint
12381simplifyCoeff expr@ (ExprVarsOnly [CoeffTermVO coeff var] :<= num)
0 commit comments