コード例 #1
0
 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);
     }
 }
コード例 #2
0
    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);
    }
コード例 #3
0
ファイル: ExpBasis.cs プロジェクト: mmiscool/NoteCAD
    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));
    }
コード例 #4
0
    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);
    }
コード例 #5
0
 public void GenerateEquations(EquationSystem sys)
 {
     sys.AddParameters(parameters);
     sys.AddEquations(equations);
 }