public void GenerateEquations(EquationSystem system) { foreach (var e in entities) { system.AddParameters(e.parameters); system.AddEquations(e.equations); } foreach (var c in constraints) { system.AddParameters(c.parameters); system.AddEquations(c.equations); } }
protected override bool OnSatisfy() { EquationSystem sys = new EquationSystem(); sys.AddParameters(parameters); var exprs = equations.ToList(); sys.AddEquations(equations); double bestI = 0.0; double min = -1.0; for (double i = 0.0; i < 1.0; i += 0.25 / 2.0) { value.value = i; sys.Solve(); double cur_value = exprs.Sum(e => Math.Abs(e.Eval())); if (min >= 0.0 && min < cur_value) { continue; } bestI = value.value; min = cur_value; } value.value = bestI; return(true); }
public void GenerateEquations(EquationSystem sys) { sys.AddParameters(parameters); sys.AddEquation(u.Magnitude() - 1.0); sys.AddEquation(v.Magnitude() - 1.0); var cross = ExpVector.Cross(u, v); var dot = ExpVector.Dot(u, v); sys.AddEquation(Exp.Atan2(cross.Magnitude(), dot) - Math.PI / 2); sys.AddEquation(n - ExpVector.Cross(u, v)); }
bool Satisfy() { EquationSystem sys = new EquationSystem(); sys.AddParameters(parameters); addAngle = false; var exprs = equations.ToList(); addAngle = true; sys.AddEquations(equations); double bestI = 0.0; double bestJ = 0.0; double min = -1.0; for (double i = 0.0; i < 1.0; i += 0.25 / 2.0) { for (double j = 0.0; j < 1.0; j += 0.25 / 2.0) { t0.value = i; t1.value = j; sys.Solve(); double cur_value = exprs.Sum(e => Math.Abs(e.Eval())); if (min >= 0.0 && min < cur_value) { continue; } bestI = t0.value; bestJ = t1.value; min = cur_value; } } t0.value = bestI; t1.value = bestJ; return(true); }
public void GenerateEquations(EquationSystem sys) { sys.AddParameters(parameters); sys.AddEquations(equations); }