예제 #1
0
        public static GaPoTNumFrame CreateGramSchmidtFrame(int vectorsCount, int refVectorIndex, out GaPoTNumFrame kirchhoffFrame)
        {
            kirchhoffFrame = CreateKirchhoffFrame(vectorsCount, refVectorIndex);

            var uPseudoScalar = new GaPoTNumMultivector()
                                .SetTerm(
                (1 << vectorsCount) - 1,
                1.0d
                );

            var cFrame = kirchhoffFrame.GetOrthogonalFrame(true);

            cFrame.AppendVector(
                -GaPoTNumUtils
                .OuterProduct(cFrame)
                .Gp(uPseudoScalar.CliffordConjugate())
                .GetVectorPart()
                );

            Debug.Assert(
                cFrame.IsOrthonormal()
                );

            Debug.Assert(
                CreateBasisFrame(vectorsCount).HasSameHandedness(cFrame)
                );

            return(cFrame);
        }
예제 #2
0
        public GaPoTNumMultivector Sp(GaPoTNumMultivector mv2)
        {
            var result = new GaPoTNumMultivector();

            foreach (var term1 in _termsDictionary.Values)
            {
                if (!mv2._termsDictionary.TryGetValue(term1.IDsPattern, out var term2))
                {
                    continue;
                }

                var value = term1.Value * term2.Value;

                if (value == 0)
                {
                    continue;
                }

                if (GaPoTNumUtils.ComputeIsNegativeEGp(term1.IDsPattern, term2.IDsPattern))
                {
                    value = -value;
                }

                result.AddTerm(new GaPoTNumMultivectorTerm(0, value));
            }

            return(result);
        }
예제 #3
0
        public GaPoTNumMultivector ApplyRotor(GaPoTNumMultivector rotor)
        {
            var r1 = rotor;
            var r2 = rotor.Reverse();

            return(r1.Gp(this).Gp(r2));
        }
예제 #4
0
        public GaPoTNumVector ApplyRotor(GaPoTNumMultivector rotor)
        {
            var r1 = rotor;
            var r2 = rotor.Reverse();
            var v  = ToMultivector();

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

            return(mv.GetVectorPart());
        }
예제 #5
0
        /// <summary>
        /// Assuming this multivector is a simple rotor, this extracts its angle and 2-blade of rotation
        /// </summary>
        /// <returns></returns>
        public Tuple <double, GaPoTNumMultivector> GetSimpleRotorAngleBlade()
        {
            var scalarPart   = GetTermValue(0);
            var bivectorPart = new GaPoTNumMultivector(GetTermsOfGrade(2));

            var halfAngle = Math.Acos(scalarPart);
            var angle     = 2.0d * halfAngle;
            var blade     = bivectorPart / Math.Sin(halfAngle);

            return(new Tuple <double, GaPoTNumMultivector>(angle, blade));
        }
예제 #6
0
        public static GaPoTNumMultivector operator -(GaPoTNumMultivector v)
        {
            var result = new GaPoTNumMultivector();

            foreach (var term in v._termsDictionary.Values)
            {
                result.AddTerm(term.IDsPattern, -term.Value);
            }

            return(result);
        }
예제 #7
0
        /// <summary>
        /// Create a simple rotor from an angle and a blade
        /// </summary>
        /// <param name="rotationAngle"></param>
        /// <param name="rotationBlade"></param>
        /// <returns></returns>
        public static GaPoTNumMultivector CreateSimpleRotor(double rotationAngle, GaPoTNumMultivector rotationBlade)
        {
            var cosHalfAngle = Math.Cos(rotationAngle / 2.0d);
            var sinHalfAngle = Math.Sin(rotationAngle / 2.0d);

            var rotationBladeScalar =
                sinHalfAngle /
                Math.Sqrt(Math.Abs(rotationBlade.Gp(rotationBlade).GetTermValue(0)));

            var rotor =
                cosHalfAngle + rotationBladeScalar * rotationBlade;

            //rotor.IsSimpleRotor();

            return(rotor);
        }
예제 #8
0
        public static GaPoTNumMultivector operator /(GaPoTNumMultivector v, double s)
        {
            s = 1.0d / s;

            var result = new GaPoTNumMultivector();

            foreach (var term in v._termsDictionary.Values)
            {
                result.AddTerm(
                    term.IDsPattern,
                    term.Value * s
                    );
            }

            return(result);
        }
예제 #9
0
        public static GaPoTNumMultivector operator +(double v2, GaPoTNumMultivector v1)
        {
            var result = new GaPoTNumMultivector();

            foreach (var term in v1._termsDictionary.Values)
            {
                result.AddTerm(
                    term.IDsPattern,
                    term.Value
                    );
            }

            result.AddTerm(0, v2);

            return(result);
        }
예제 #10
0
        public GaPoTNumMultivector Gp(GaPoTNumMultivector mv2)
        {
            var result = new GaPoTNumMultivector();

            foreach (var term1 in _termsDictionary.Values)
            {
                foreach (var term2 in mv2._termsDictionary.Values)
                {
                    var term = term1.Gp(term2);

                    if (term.Value != 0)
                    {
                        result.AddTerm(term);
                    }
                }
            }

            return(result);
        }
예제 #11
0
        public static GaPoTNumMultivector operator *(GaPoTNumMultivector v1, GaPoTNumMultivector v2)
        {
            var result = new GaPoTNumMultivector();

            foreach (var term1 in v1._termsDictionary.Values)
            {
                foreach (var term2 in v2._termsDictionary.Values)
                {
                    var term = term1.Gp(term2);

                    if (term.Value != 0)
                    {
                        result.AddTerm(term);
                    }
                }
            }

            return(result);
        }
예제 #12
0
 public GaPoTNumMultivector Subtract(GaPoTNumMultivector v)
 {
     return(this - v);
 }
예제 #13
0
 public GaPoTNumMultivector Add(GaPoTNumMultivector v)
 {
     return(this + v);
 }
예제 #14
0
 public GaPoTNumVector GetProjectionOnBlade(GaPoTNumMultivector blade)
 {
     return(ToMultivector().Lcp(blade).Lcp(blade.Inverse()).GetVectorPart());
 }
예제 #15
0
 public GaPoTNumMultivector GetRotorToVector(GaPoTNumVector v2)
 {
     return(GaPoTNumMultivector.CreateSimpleRotor(this, v2));
 }
예제 #16
0
 public GaPoTNumMultivector Gp(GaPoTNumMultivector v)
 {
     return(ToMultivector().Gp(v));
 }