Beispiel #1
0
        public static GaPoTNumBiversor operator -(GaPoTNumBiversor v1, GaPoTNumBiversor v2)
        {
            var biversor = new GaPoTNumBiversor();

            biversor.AddTerms(v1._termsDictionary.Values);
            biversor.AddTerms(v2._termsDictionary.Values.Select(t => - t));

            return(biversor);
        }
        public GaPoTNumVector ApplyRotor(GaPoTNumBiversor rotor)
        {
            var r1 = rotor.ToMultivector();
            var r2 = rotor.Reverse().ToMultivector();
            var v  = ToMultivector();

            var mv = r1.Gp(v).Gp(r2);

            return(mv.GetVectorPart());
        }
Beispiel #3
0
        public GaPoTNumBiversor ScaleBy(double s)
        {
            var result = new GaPoTNumBiversor();

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

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

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

            return(result);
        }
        public static GaPoTNumBiversor[] Gp(this GaPoTNumVector[] vectorsList1, GaPoTNumVector[] vectorsList2)
        {
            if (vectorsList1.Length != vectorsList2.Length)
            {
                throw new InvalidOperationException();
            }

            var results = new GaPoTNumBiversor[vectorsList1.Length];

            for (var i = 0; i < vectorsList1.Length; i++)
            {
                results[i] = vectorsList1[i].Gp(vectorsList2[i]);
            }

            return(results);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
        }
        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);
        }
        /// <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);
        }
 public GaPoTNumVector Gp(GaPoTNumBiversor bv)
 {
     return(this * bv);
 }