Example #1
0
        public GaPoTNumBiversor NegativeReverse()
        {
            var result = new GaPoTNumBiversor();

            foreach (var pair in _termsDictionary)
            {
                if (pair.Value.IsScalar)
                {
                    result.AddTerm(-pair.Value);
                }
                else
                {
                    result.AddTerm(pair.Value);
                }
            }

            return(result);
        }
Example #2
0
        private static GaPoTNumBiversor GaPoTNumParseBiversor(IronyParsingResults parsingResults, ParseTreeNode rootNode)
        {
            if (rootNode.ToString() != "biversor")
            {
                throw new SyntaxErrorException(parsingResults.ToString());
            }

            var biversor = new GaPoTNumBiversor();

            var vectorNode = rootNode;

            foreach (var vectorElementNode in vectorNode.ChildNodes)
            {
                if (vectorElementNode.ToString() == "biversorTerm0")
                {
                    //Scalar term
                    var value = double.Parse(vectorElementNode.ChildNodes[0].FindTokenAndGetText());

                    biversor.AddTerm(1, 1, value);
                }
                else if (vectorElementNode.ToString() == "biversorTerm2")
                {
                    //Biversor term
                    var value = double.Parse(vectorElementNode.ChildNodes[0].FindTokenAndGetText());
                    var id1   = int.Parse(vectorElementNode.ChildNodes[1].FindTokenAndGetText());
                    var id2   = int.Parse(vectorElementNode.ChildNodes[2].FindTokenAndGetText());

                    if (id1 < 0 || id2 < 0)
                    {
                        throw new SyntaxErrorException(parsingResults.ToString());
                    }

                    biversor.AddTerm(id1, id2, value);
                }
                else
                {
                    throw new SyntaxErrorException(parsingResults.ToString());
                }
            }

            return(biversor);
        }
Example #3
0
        public GaPoTNumBiversor ScaleBy(double s)
        {
            var result = new GaPoTNumBiversor();

            foreach (var pair in _termsDictionary)
            {
                result.AddTerm(s * pair.Value);
            }

            return(result);
        }
Example #4
0
        public GaPoTNumBiversor Negative()
        {
            var result = new GaPoTNumBiversor();

            foreach (var pair in _termsDictionary)
            {
                result.AddTerm(-pair.Value);
            }

            return(result);
        }
Example #5
0
        public GaPoTNumBiversor GetBiversorPart()
        {
            var biversor = new GaPoTNumBiversor();

            var scalarValue = GetTermValue(0);

            if (scalarValue != 0.0d)
            {
                biversor.AddTerm(new GaPoTNumBiversorTerm(scalarValue));
            }

            biversor.AddTerms(
                GetTermsOfGrade(2).Select(t => t.ToBiversorTerm())
                );

            return(biversor);
        }
        /// <summary>
        /// The geometric product of two GAPoT vectors is a biversor
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <returns></returns>
        public static GaPoTNumBiversor operator *(GaPoTNumVector v1, GaPoTNumVector v2)
        {
            var biversor = new GaPoTNumBiversor();

            foreach (var term1 in v1.GetTerms())
            {
                foreach (var term2 in v2.GetTerms())
                {
                    var scalarValue = term1.Value * term2.Value;

                    biversor.AddTerm(
                        term1.TermId,
                        term2.TermId,
                        scalarValue
                        );
                }
            }

            return(biversor);
        }