예제 #1
0
        void IFieldConsumer.Add(IPhysicalField field)
        {
            if (this.field != null)
            {
                throw new Exception("Field of this object already exist");
            }
            if (!(field is IPositionObject))
            {
                throw new Exception("Field has no postion");
            }
            this.field = field;
            IPositionObject po = field as IPositionObject;

            fieldFrame = ReferenceFrame.GetOwnFrame(po.Position);
            CreateDelegate();
        }
예제 #2
0
        bool CreateConside()
        {
            if (!(target is IReferenceFrame))
            {
                if (target is IPosition)
                {
                    UpdateAll    = UpdateCoinDistance;
                    measurements = new IMeasurement[]
                    {
                        new Measurement(GetDistance, names[3])
                    };
                }
                return(false);
            }
            IReferenceFrame f = target as IReferenceFrame;
            ReferenceFrame  o = f.Own;
            ReferenceFrame  p = ReferenceFrame.GetOwnFrame(source);

            if (p == o)
            {
                return(false);
            }
            UpdateAll = UpdateCoinDistance;
            if ((source is IVelocity) & (target is IVelocity))
            {
                vSource    = source as IVelocity;
                UpdateAll += UpdateCoinVelocity;
            }
            if (oTarget != null)
            {
                UpdateAll += UpdateOrientationCoordinates;
            }
            if (oTarget != null)
            {
                UpdateAll += UpdateOrientationVelocity;
            }
            if (aTarget != null)
            {
                UpdateAll += AddAngularVelocity;
            }

            if ((oSource != null) & (oTarget != null))
            {
                UpdateAll += UpdateQuaternion;
            }
            return(true);
        }
예제 #3
0
        void UpdateRelativePosition()
        {
            double[] y    = source.Position;
            double[] x    = target.Position;
            double   dist = 0;

            for (int i = 0; i < 3; i++)
            {
                double dd = y[i] - x[i];
                dist       += dd * dd;
                relative[i] = dd;
            }
            distance = Math.Sqrt(dist);
            ReferenceFrame f = ReferenceFrame.GetOwnFrame(target);

            f.CalculateRotatedPosition(relative, relativePos);
        }
예제 #4
0
        private void CreateMeasurements()
        {
            measurements = new IMeasurement[0];
            if (source == null | target == null)
            {
                return;
            }
            if (!CreateConside())
            {
                return;
            }
            Func <object> mpd = GetDistance;

            GetParameters(target, ref vTarget, ref oTarget, ref aTarget);
            GetParameters(source, ref vSource, ref oSource, ref aSource);
            CreateConside();
            sourceFrame = ReferenceFrame.GetOwnFrame(source);
            targetFrame = ReferenceFrame.GetOwnFrame(target);
            PostCreateMeasurements();
        }