Пример #1
0
 private void PostCreateFrame()
 {
     try
     {
         frame  = this.GetFrame();
         acc    = frame.GetSimpleObject <IAcceleration>("Object should have acceleration");
         angvel = frame.GetSimpleObject <IAngularVelocity>("Object should have angular velocity");
         vel    = frame.GetSimpleObject <IVelocity>("Object should have velocity");
         angacc = frame.GetSimpleObject <IAngularAcceleration>("Object should have angular acceleration");
     }
     catch (Exception e)
     {
         e.ShowError(10);
         IPosition p = this;
         p.Parent = null;
         throw e;
     }
 }
Пример #2
0
        /// <summary>
        /// Sets state
        /// </summary>
        /// <param name="baseFrame">Base frame</param>
        /// <param name="relative">Relative frame</param>
        public override void Set(ReferenceFrame baseFrame, ReferenceFrame relative)
        {
            base.Set(baseFrame, relative);
            IAcceleration        ab  = baseFrame as IAcceleration;
            IAcceleration        ar  = relative as IAcceleration;
            IAngularAcceleration arn = relative as IAngularAcceleration;
            IVelocity            vb  = baseFrame as IVelocity;
            IVelocity            vr  = relative as IVelocity;
            IAngularVelocity     anb = baseFrame as IAngularVelocity;
            IAngularVelocity     anr = relative as IAngularVelocity;

            double[] rp = Position;
            double[,] m = Matrix;
            double[] omr = anr.Omega;
            StaticExtensionVector3D.VectorPoduct(omr, vr.Velocity, tempV);
            double om2 = StaticExtensionVector3D.Square(omr);

            double[] eps = arn.AngularAcceleration;
            StaticExtensionVector3D.VectorPoduct(eps, rp, temp);
            for (int i = 0; i < 3; i++)
            {
                tempV[i] *= 2;
                tempV[i] += om2 * rp[i] + relativeAcceleration[i] + temp[i];
            }
            RealMatrix.Multiply(m, tempV, acceleration);
            double[]     omb = anb.Omega;
            IOrientation orr = relative as IOrientation;

            double[,] mrr = orr.Matrix;
            RealMatrix.Multiply(omb, mrr, temp);
            StaticExtensionVector3D.VectorPoduct(temp, omr, tempV);
            for (int i = 0; i < 3; i++)
            {
                temp[i] = eps[i] + tempV[i];
            }
            RealMatrix.Multiply(temp, m, angularAcceleration);
        }
Пример #3
0
 /// <summary>
 /// Updates itself
 /// </summary>
 public override void Update()
 {
     try
     {
         this.FullReset();
         IDataConsumer cons = this;
         cons.UpdateChildrenData();
         ReferenceFrame relative = Relative;
         IPosition      p        = relative;
         double[]       x        = p.Position;
         ReferenceFrame parent   = this.GetParentFrame();
         for (int i = 0; i < 3; i++)
         {
             x[i] = (double)measurements[i].Parameter();
         }
         if (relative is IVelocity)
         {
             IVelocity vel = relative as IVelocity;
             double[]  v   = vel.Velocity;
             for (int i = 0; i < 3; i++)
             {
                 IDerivation d = measurements[i] as IDerivation;
                 v[i] = Measurement.GetDouble(d.Derivation);
             }
         }
         double[] qua = relative.Quaternion;
         for (int i = 0; i < qua.Length; i++)
         {
             IMeasurement m = measurements[i + 3];
             qua[i] = (double)m.Parameter();
         }
         relative.SetMatrix();
         if (relative is IAngularVelocity)
         {
             IAngularVelocity av = relative as IAngularVelocity;
             double[]         om = av.Omega;
             IOrientation     or = relative as IOrientation;
             for (int i = 0; i < 4; i++)
             {
                 IDerivation d = measurements[i + 3] as IDerivation;
                 der[i] = Measurement.GetDouble(d.Derivation);
             }
             Vector3D.StaticExtensionVector3D.CalculateDynamics(or.Quaternion, der, om, qd);
         }
         if (relative is IAcceleration)
         {
             IAcceleration        acc    = relative as IAcceleration;
             IAngularAcceleration anc    = relative as IAngularAcceleration;
             double[]             linacc = acc.RelativeAcceleration;
             for (int i = 0; i < linacc.Length; i++)
             {
                 linacc[i] = Measurement.GetDouble(secondDeriM[i]);
             }
             for (int i = 0; i < 4; i++)
             {
                 angsec[i] = Measurement.GetDouble(secondDeriM[i + 3]);
             }
             IAngularVelocity av     = relative as IAngularVelocity;
             double[]         om     = av.Omega;
             IOrientation     or     = relative as IOrientation;
             double[]         angacc = anc.AngularAcceleration;
             Vector3D.StaticExtensionVector3D.CalculateAcceleratedDynamics(or.Quaternion, der, om, qd, angsec, angacc);
         }
         base.Update();
     }
     catch (Exception exception)
     {
         exception.ShowError(10);
         //!!!  OLD           this.Throw(ex);
     }
 }