Exemplo n.º 1
0
        private void TauSigmaInertia()
        {
            double.TryParse(textBox1.Text, out a);
            double.TryParse(textBox9.Text, out b);
            double.TryParse(textBox8.Text, out c);
            double.TryParse(textBox7.Text, out d);
            if (a == 0 || b == 0 || c == 0 || d == 0)
            {
                MessageBox.Show("Invalid input");
            }
            if (d > b / 2)
            {
                MessageBox.Show("d<b/2 !");
            }
            if (c > a / 2)
            {
                MessageBox.Show("c<a/2 !");
            }
            Ix            = ((a * a * a * b) - ((b - d) * (b - d) * (b - d) * (a - c - c))) / 12;
            textBox4.Text = "Ix = " + Ix.ToString() + "mm4";

            Tau           = T1 / ((a * b) - (a - c - c) * (b - d));
            textBox5.Text = Tau.ToString();

            Sigma         = (M1 * a) / (Ix * 2);
            textBox6.Text = Sigma.ToString();
        }
        // -------------------- ScanWord_IsolateWord ---------------------------
        // We have a word starting at InBx. Scan to the end of the word.
        // Returns the word in the InOutResults parm.
        // Returns the word delim in the return argument.
        private static ScanPatternResults ScanWord_IsolateWord(
            BoundedString InBoundedString,
            int InBx,
            ref WordCursor InOutResults,
            TextTraits Traits)
        {
            int                Bx, Ix, Lx;
            string             wordText;
            ScanPatternResults spr = null;

            Bx = InBx;
            char ch1 = InBoundedString.String[Bx];

            // is start of a verbatim string literal
            if ((Traits.VerbatimLiteralPattern != null) &&
                (Traits.VerbatimLiteralPattern.Match(InBoundedString, Bx)))
            {
            }

            // is quoted. the word runs to the closing quote.
            else if (IsOpenQuoteChar(ch1) == true)
            {
                Ix = ScanCloseQuote(InBoundedString.String, Bx, Traits.QuoteEncapsulation);
                if ((Ix == -1) || (Ix > InBoundedString.Ex))
                {
                    throw (new ApplicationException(
                               "Closing quote not found starting at position " +
                               Bx.ToString() + " in " + InBoundedString.String));
                }
                Lx       = Ix - Bx + 1;
                wordText = InBoundedString.String.Substring(Bx, Lx);
                InOutResults.SetWord(wordText, WordClassification.Quoted, Bx);

                // setup the non word which follows the closing quote.
                Bx = Ix + 1;
                if (InBoundedString.IsOutsideBounds(Bx))
                {
                    spr = new ScanPatternResults(-1);
                }
                else
                {
                    // the char that follows the closing quote must be a delim
                    spr = ScanEqualAny(InBoundedString, Bx, Traits.NonWordPatterns);
                    if (spr.FoundPos != Bx)
                    {
                        throw new ApplicationException(
                                  "invalid char follows close quote at pos " + Ix.ToString() +
                                  " in " + Stringer.Head(InBoundedString.String, 80));
                    }
                }
            }
            else
            {
                // Scan the string for any of the non word patterns spcfd in Traits.
                DelimClassification sprdc = DelimClassification.None;
                spr = ScanEqualAny(InBoundedString, Bx, Traits.NonWordPatterns);
                if (spr.IsNotFound == false)
                {
                    sprdc = spr.FoundPat.DelimClassification;
                }

                // a quote character within the name.  this is an error.
                if (sprdc == DelimClassification.Quote)
                {
                    throw new ApplicationException(
                              "quote character immed follows name character at position " +
                              spr.FoundPos.ToString() + " in " + InBoundedString.String);
                }

                // no delim found. all word to the end of the string.
                else if (spr.IsNotFound)
                {
                    wordText = InBoundedString.Substring(Bx);
                    InOutResults.SetWord(wordText, WordClassification.Identifier, InBx);
                }

                // found an open named brace char
                else if (sprdc == DelimClassification.OpenNamedBraced)
                {
                    ScanWord_IsolateWord_Braced(
                        InBoundedString, Bx, spr, ref InOutResults, Traits);
                }

                // delim is same position as the word.  so there is no word, only a delim.
                else if (spr.FoundPos == InBx)
                {
                    if (Scanner.IsOpenBraced(sprdc))
                    {
                        InOutResults.SetWord(
                            spr.FoundPat.PatternValue, WordClassification.OpenContentBraced, Bx,
                            spr.FoundPat.LeadChar);
                    }

                    // start of CommentToEnd comment. This is a word, not a delim. Find the
                    // end of the comment and set the delim to that end position.
                    else if (sprdc == DelimClassification.CommentToEnd)
                    {
                        spr = ScanWord_IsolateWord_CommentToEnd(
                            InBoundedString, spr.FoundPos, ref InOutResults, Traits);
                    }

                    else
                    {
                        InOutResults.SetNullWord();
                    }
                }

                // we have a word that ends with a delim.
                else
                {
                    Lx       = spr.FoundPos - InBx;
                    wordText = InBoundedString.Substring(InBx, Lx);
                    InOutResults.SetWord(wordText, WordClassification.Identifier, InBx);
                }
            }

            // return ScanPatternResults of the delim that ends the word.
            return(spr);
        }