Esempio n. 1
0
 public DerivedFrameSystem(GaFrame baseFrame, GaFrame derivedFrame, GaOuterMorphism derivedToBaseOm)
 {
     BaseFrame       = baseFrame;
     DerivedFrame    = derivedFrame;
     DerivedToBaseOm = derivedToBaseOm;
     BaseToDerivedOm = derivedToBaseOm.InverseOm();
 }
Esempio n. 2
0
        /// <summary>
        /// Create a derived frame system using a change of basis matrix for the basis vectors
        /// </summary>
        /// <param name="baseFrame">The base frame. It may be any kind of frame</param>
        /// <param name="cbm">The 'Change Of Basis Vectors' matrix. It must be invertable</param>
        /// <returns></returns>
        public static DerivedFrameSystem CreateDerivedCbmFrameSystem(GaFrame baseFrame, MathematicaMatrix cbm)
        {
            var baseIpm         = baseFrame.Ipm.ToMathematicaMatrix();
            var cbmTrans        = (MathematicaMatrix)cbm.Transpose();
            var cbmInverseTrans = (MathematicaMatrix)cbmTrans.Inverse();

            var ipm = cbm * baseIpm * cbmTrans;

            var baseToDerivedOm = GaOuterMorphismFull.Create(cbmInverseTrans);
            var derivedToBaseOm = GaOuterMorphismFull.Create(cbmTrans);

            if (ipm.IsDiagonal())
            {
                var derivedFrame = CreateOrthogonal(ipm.GetDiagonal());
                return(new DerivedFrameSystem(baseFrame, derivedFrame, derivedToBaseOm, baseToDerivedOm));
            }

            if (baseFrame.IsOrthogonal)
            {
                var derivedFrame = new GaFrameNonOrthogonal(baseFrame, ipm, derivedToBaseOm, baseToDerivedOm);
                return(derivedFrame.Dfs);
            }

            var gaFrame =
                //new GaFrameNonOrthogonal(baseFrame, ipm, derivedToBaseOm, baseToDerivedOm);
                CreateNonOrthogonalFromIpm(ipm.ToMathematicaMatrix());

            return(gaFrame.Dfs);
            //return new DerivedFrameSystem(baseFrame, gaFrame, derivedToBaseOm, baseToDerivedOm);
        }
Esempio n. 3
0
        internal GaFrameNonOrthogonal(GaFrame baseOrthoFrame, ISymbolicMatrix ipm, GaOuterMorphism derivedToBaseOm, GaOuterMorphism baseToDerivedOm)
        {
            if (baseOrthoFrame.IsOrthogonal == false)
            {
                throw new GMacSymbolicException("Base frame must be orthogonal");
            }

            if (ipm.IsSymmetric() == false || ipm.IsDiagonal())
            {
                throw new GMacSymbolicException("Inner product matrix must be symmetric and non-diagonal");
            }

            InnerProductMatrix = ipm.ToMathematicaMatrix();
            Dfs = new DerivedFrameSystem(baseOrthoFrame, this, derivedToBaseOm, baseToDerivedOm);
        }
Esempio n. 4
0
        /// <summary>
        /// Create a derived frame system where the derived frame is the reciprocal of the base frame
        /// </summary>
        /// <param name="baseFrame"></param>
        /// <returns></returns>
        public static DerivedFrameSystem CreateReciprocalCbmFrameSystem(GaFrame baseFrame)
        {
            if (baseFrame.IsOrthogonal)
            {
                var cbmat = baseFrame.Ipm.Inverse();

                var b2DOm = GaOuterMorphismFull.Create(baseFrame.Ipm);
                var d2BOm = GaOuterMorphismFull.Create(cbmat);

                var derivedFrame = CreateOrthogonal(cbmat.GetDiagonal());
                return(new DerivedFrameSystem(baseFrame, derivedFrame, d2BOm, b2DOm));
            }

            var cbmArray = new MathematicaScalar[baseFrame.VSpaceDimension, baseFrame.VSpaceDimension];

            var mv2 = baseFrame.CreateInverseUnitPseudoScalar();

            for (var i = 0; i < baseFrame.VSpaceDimension; i++)
            {
                var id  = (1 << i) ^ baseFrame.MaxBasisBladeId;
                var mv1 = GaMultivector.CreateTerm(baseFrame.GaSpaceDimension, id, SymbolicUtils.Constants.One);

                var mv = baseFrame.Lcp(mv1, mv2);

                foreach (var term in mv)
                {
                    var j = term.Key.BasisBladeIndex();

                    if ((i & 1) == 1)
                    {
                        cbmArray[i, j] = term.Value;
                    }
                    else
                    {
                        cbmArray[i, j] = -term.Value;
                    }
                }
            }

            var cbm = MathematicaMatrix.CreateFullMatrix(SymbolicUtils.Cas, cbmArray);

            return(CreateDerivedCbmFrameSystem(baseFrame, cbm));
        }