Пример #1
0
    // LLL
    private bool ResolveBottomLLL(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 3 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomLengthCondition && bottomConditions[2] is BottomLengthCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomLengthCondition condition2 = (BottomLengthCondition)bottomConditions[1];
            BottomLengthCondition condition3 = (BottomLengthCondition)bottomConditions[2];

            float a, b, c;

            converter.aER = new EdgeRefer(condition1.edge.id1, condition1.edge.id2);
            converter.bER = new EdgeRefer(condition2.edge.id1, condition2.edge.id2);
            converter.cER = new EdgeRefer(condition3.edge.id1, condition3.edge.id2);

            a = condition1.length;
            b = condition2.length;
            c = condition3.length;

            judge = BottomLLL(a, b, c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }

        return(false);
    }
Пример #2
0
    // L  ->  LAL
    private bool ResolveBottomL(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 1 &&
            bottomConditions[0] is BottomLengthCondition)
        {
            BottomLengthCondition condition = (BottomLengthCondition)bottomConditions[0];

            float a, b, c, alpha;

            int id3 = EdgeOppositeIndex(condition.edge);

            converter.aER = new EdgeRefer(condition.edge.id1, condition.edge.id2);
            converter.bER = new EdgeRefer(condition.edge.id1, id3);
            converter.cER = new EdgeRefer(condition.edge.id2, id3);

            a     = condition.length;
            b     = EdgeIndexLength(condition.edge.id1, id3);
            c     = EdgeReferLength(converter.cER);
            alpha = CornerIndexAngle(condition.edge.id2, condition.edge.id1, id3);

            judge = BottomLAL(a, b, alpha, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }
        return(false);
    }
Пример #3
0
    public void AddBottomLength()
    {
        BottomLengthCondition condition = new BottomLengthCondition(edge.x, edge.y, length);

        geometry.Constructor.AddCondition(condition);

        PrintAtttributes();
    }
Пример #4
0
    public BottomLengthConditionState(Tool tool, Condition condition, Geometry geometry) : base(tool, condition)
    {
        if (condition is BottomLengthCondition)
        {
            this.condition = (BottomLengthCondition)condition;
        }

        if (geometry is TriPyramid)
        {
            this.geometry = (TriPyramid)geometry;
        }
    }
Пример #5
0
    // ALA
    private bool ResolveBottomALA(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 3 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomAngleCondition && bottomConditions[2] is BottomAngleCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomAngleCondition  condition2 = (BottomAngleCondition)bottomConditions[1];
            BottomAngleCondition  condition3 = (BottomAngleCondition)bottomConditions[2];

            if (IsEdgeOppositeCorner(condition1.edge, condition2.corner) || IsEdgeOppositeCorner(condition1.edge, condition3.corner))
            {
                int   index = EdgeOppositeIndex(new EdgeRefer(condition2.corner.id2, condition3.corner.id2));
                float angle = 180 - condition2.angle - condition3.angle;
                BottomAngleCondition conditionN = new BottomAngleCondition(condition2.corner.id2, index, condition3.corner.id2, angle);
                if (IsEdgeOppositeCorner(condition1.edge, condition2.corner))
                {
                    condition2 = conditionN;
                }
                else if (IsEdgeOppositeCorner(condition1.edge, condition3.corner))
                {
                    condition3 = conditionN;
                }
            }

            float a, b, c, alpha, beta;

            int id3 = EdgeOppositeIndex(condition1.edge);

            converter.aER = new EdgeRefer(condition1.edge.id1, condition1.edge.id2);
            converter.bER = new EdgeRefer(condition2.corner.id2, id3);
            converter.cER = new EdgeRefer(condition3.corner.id2, id3);

            a     = condition1.length;
            b     = EdgeReferLength(converter.bER);
            c     = EdgeReferLength(converter.cER);
            alpha = condition2.angle;
            beta  = condition3.angle;

            judge = BottomALA(a, alpha, beta, ref b, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }

        return(false);
    }
Пример #6
0
    // LLA
    private bool ResolveBottomLLA(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 3 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomLengthCondition && bottomConditions[2] is BottomAngleCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomLengthCondition condition2 = (BottomLengthCondition)bottomConditions[1];
            BottomAngleCondition  condition3 = (BottomAngleCondition)bottomConditions[2];

            bool isLLA = IsEdgeOppositeCorner(condition1.edge, condition3.corner) || IsEdgeOppositeCorner(condition2.edge, condition3.corner);
            if (!isLLA)
            {
                return(false);
            }

            if (IsEdgeOppositeCorner(condition1.edge, condition3.corner))
            {
                SwapCondition <BottomLengthCondition>(ref condition1, ref condition2);
            }

            float a, b, c, alpha;

            int id3 = EdgeOppositeIndex(condition1.edge);

            converter.aER = new EdgeRefer(condition1.edge.id1, condition1.edge.id2);
            converter.bER = new EdgeRefer(condition2.edge.id1, condition2.edge.id2);
            converter.cER = new EdgeRefer(condition3.corner.id2, id3);

            a     = condition1.length;
            b     = condition2.length;
            c     = EdgeReferLength(converter.cER);
            alpha = condition3.angle;

            judge = BottomLLA(a, b, alpha, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }

        return(false);
    }
Пример #7
0
    public override Condition GenerateCondition(Geometry geometry, FormInput formInput)
    {
        bool valid = ValidateInput(geometry, formInput);

        if (!valid)
        {
            return(null);
        }

        FormElement formElement = (FormElement)formInput.inputs[0];

        string[] fields  = formElement.fields;
        int      id1     = geometry.SignVertex(fields[0]);
        int      id2     = geometry.SignVertex(fields[1]);
        FormNum  formNum = (FormNum)formInput.inputs[2];
        BottomLengthCondition condition = new BottomLengthCondition(id1, id2, formNum.num);

        return(condition);
    }
Пример #8
0
    // LL  ->  LAL
    private bool ResolveBottomLL(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 2 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomLengthCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomLengthCondition condition2 = (BottomLengthCondition)bottomConditions[1];

            if (condition1.edge.id1 == condition2.edge.id2)
            {
                condition2.edge.SwapIndex();
            }
            if (condition1.edge.id2 == condition2.edge.id1)
            {
                condition1.edge.SwapIndex();
            }
            if (condition1.edge.id2 == condition2.edge.id2)
            {
                condition1.edge.SwapIndex();
                condition2.edge.SwapIndex();
            }

            float a, b, c, alpha;

            converter.aER = new EdgeRefer(condition1.edge.id1, condition1.edge.id2);
            converter.bER = new EdgeRefer(condition2.edge.id1, condition2.edge.id2);
            converter.cER = new EdgeRefer(condition1.edge.id2, condition2.edge.id2);

            a     = condition1.length;
            b     = condition2.length;
            c     = EdgeReferLength(converter.cER);
            alpha = CornerIndexAngle(condition1.edge.id2, condition1.edge.id1, condition2.edge.id2);

            judge = BottomLAL(a, b, alpha, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }
        return(false);
    }
Пример #9
0
    // AL -> LAL
    private bool ResolveBottomAL(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 2 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomAngleCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomAngleCondition  condition2 = (BottomAngleCondition)bottomConditions[1];

            bool isAL = IsEdgeAdjacentCorner(condition1.edge, condition2.corner);
            if (!isAL)
            {
                return(false);
            }

            float a, b, c, alpha;

            int id3 = EdgeOppositeIndex(condition1.edge);

            converter.aER = new EdgeRefer(condition1.edge.id1, condition1.edge.id2);
            converter.bER = new EdgeRefer(condition2.corner.id2, id3);
            converter.cER = new EdgeRefer(condition2.corner.id1, condition2.corner.id3);

            a     = condition1.length;
            b     = EdgeIndexLength(condition2.corner.id2, id3);
            c     = EdgeReferLength(converter.cER);
            alpha = condition2.angle;

            judge = BottomLAL(a, b, alpha, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }

        return(false);
    }
Пример #10
0
    // LA -> LLA
    private bool ResolveBottomLA(BottomConverter converter, out bool judge)
    {
        judge = false;

        if (bottomConditions.Count == 2 &&
            bottomConditions[0] is BottomLengthCondition && bottomConditions[1] is BottomAngleCondition)
        {
            BottomLengthCondition condition1 = (BottomLengthCondition)bottomConditions[0];
            BottomAngleCondition  condition2 = (BottomAngleCondition)bottomConditions[1];

            bool isLA = IsEdgeOppositeCorner(condition1.edge, condition2.corner);
            if (!isLA)
            {
                return(false);
            }

            float a, b, c, alpha;

            converter.aER = new EdgeRefer(condition2.corner.id2, condition2.corner.id1);
            converter.bER = new EdgeRefer(condition2.corner.id1, condition2.corner.id3);
            converter.cER = new EdgeRefer(condition2.corner.id2, condition2.corner.id3);

            b     = condition1.length;
            alpha = condition2.angle;
            a     = Mathf.Min(b / Mathf.Sin(alpha * Mathf.Deg2Rad), EdgeIndexLength(condition2.corner.id2, condition2.corner.id1));
            c     = EdgeReferLength(converter.cER);

            judge = BottomLLA(a, b, alpha, ref c);

            ConverterSetABC(converter, a, b, c);

            return(true);
        }

        return(false);
    }