コード例 #1
0
        private static bool SatisfyGeneralForm(Equation equation,
            out Circle circle)
        {
            circle = null;
            var term = equation.Lhs as Term;

            if (term != null && term.Op.Method.Name.Equals("Add"))
            {
                var lst = term.Args as List<object>;
                if (lst != null && lst.Count == 3)
                {
                    bool isNum = LogicSharp.IsNumeric(lst[2]);

                    if (isNum)
                    {
                        double dNum;
                        LogicSharp.IsDouble(lst[2], out dNum);
                        dNum *= -1;
                        object coeffX, coeffY;
                        bool xTerm1 = IsXSquareTerm(lst[0], out coeffX);
                        bool yTerm1 = IsYSquareTerm(lst[1], out coeffY);
                        if (xTerm1 && yTerm1)
                        {
                            var pt = new Point(coeffX, coeffY);
                            circle = new Circle(pt, Math.Pow(dNum, 0.5));
                            return true;
                        }
                    }
                }
            }
            return false;
        }
コード例 #2
0
ファイル: Circle.cs プロジェクト: buptkang/Relation.Logic
        public CircleSymbol(Circle _circle)
            : base(_circle)
        {

        }
コード例 #3
0
        private static bool SatisfySpecialForm(Equation equation, out Circle circle)
        {
            circle = null;

            bool isRhsNum = LogicSharp.IsNumeric(equation.Rhs);
            if (!isRhsNum) return false;
            double dNum;
            LogicSharp.IsDouble(equation.Rhs, out dNum);
            var term = equation.Lhs as Term;
            if (term == null) return false;
            if (!term.Op.Method.Name.Equals("Add")) return false;
            var lst = term.Args as List<object>;
            if (lst == null || lst.Count != 2) return false;

            object coeffX, coeffY;
            bool xTerm = IsXSquareTerm(lst[0], out coeffX);
            bool yTerm = IsYSquareTerm(lst[1], out coeffY);
            if (xTerm && yTerm)
            {
                var pt = new Point(coeffX, coeffY);
                circle = new Circle(pt, Math.Pow(dNum,0.5));
                return true;
            }
            xTerm = false;
            yTerm = false;
            xTerm = IsXSquareTerm(lst[1], out coeffX);
            yTerm = IsYSquareTerm(lst[0], out coeffY);
            if (xTerm && yTerm)
            {
                var pt = new Point(coeffX, coeffY);
                circle = new Circle(pt, Math.Pow(dNum, 0.5));
                return true;
            }
            return false;
        }