Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        protected void Draw(Graphics g, int w, int h)
        {
            IReferenceFrame         f     = collection;
            ReferenceFrame          frame = f.Own;
            IPositionCollection     pos   = collection.Positions;
            ICollection <IPosition> l     = pos.Positions;

            g.FillRectangle(backBrush, 0, 0, (float)w, (float)h);
            foreach (IPosition p in l)
            {
                frame.GetPositon(p, auxPos);
                double x  = auxPos[0];
                double y  = auxPos[1];
                int    xx = (int)(((x - x1) / (x2 - x1)) * (double)w);
                int    yy = (int)(((y - y1) / (y2 - y1)) * (double)h);
                Brush  br = drawBrush;
                Draw(p, g, xx, yy);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Prepares itself
        /// </summary>
        protected virtual void Prepare()
        {
            IReferenceFrame     f         = collection;
            ReferenceFrame      frame     = f.Own;
            IPositionCollection positions = collection.Positions;
            bool first = true;

            foreach (IPosition p in positions.Positions)
            {
                frame.GetPositon(p, auxPos);
                if (first)
                {
                    x1    = auxPos[0];
                    x2    = x1;
                    y1    = auxPos[1];
                    y2    = y1;
                    first = false;
                    continue;
                }
                double x = auxPos[0];
                double y = auxPos[1];
                if (x < x1)
                {
                    x1 = x;
                }
                if (x > x2)
                {
                    x2 = x;
                }
                if (y < y1)
                {
                    y1 = y;
                }
                if (y > y2)
                {
                    y2 = y;
                }
            }
        }
Ejemplo n.º 4
0
        private static void prepare(IReferenceFrame frame, List <IPosition> frames)
        {
            List <IPosition> children = frame.Children;

            frames.Add(frame);
            foreach (IPosition p in children)
            {
                if (frames.Contains(p))
                {
                    continue;
                }
                if (p is IReferenceFrame)
                {
                    IReferenceFrame f = p as IReferenceFrame;
                    prepare(f, frames);
                }
                else
                {
                    frames.Add(p);
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Preparation operation
        /// </summary>
        /// <param name="collection">Desktop</param>
        /// <returns>List of position objects</returns>
        static public List <IPosition> Prepare(IComponentCollection collection)
        {
            List <IPosition> frames = new List <IPosition>();

            if (collection == null)
            {
                return(frames);
            }
            IEnumerable <object> c = collection.AllComponents;

            foreach (object o in c)
            {
                if (!(o is IObjectLabel))
                {
                    continue;
                }
                IObjectLabel    lab = o as IObjectLabel;
                ICategoryObject co  = lab.Object;
                if (!(co is IReferenceFrame))
                {
                    if (co is IPosition)
                    {
                        IPosition p = co as IPosition;
                        if (p.Parent == null)
                        {
                            frames.Add(p);
                        }
                    }
                    continue;
                }
                IReferenceFrame f = co as IReferenceFrame;
                if (f.Parent != null)
                {
                    continue;
                }
                prepare(f, frames);
            }
            return(frames);
        }
Ejemplo n.º 6
0
        void GetParameters(IPosition p, ref IVelocity velocity, ref IOrientation orientation, ref IAngularVelocity om)
        {
            velocity    = null;
            orientation = null;
            om          = null;
            IPosition pa = p;

            if (p is IReferenceFrame)
            {
                IReferenceFrame f = p as IReferenceFrame;
                pa = f.Own;
            }
            if (pa is IVelocity)
            {
                velocity = pa as IVelocity;
            }
            else
            {
                velocity = null;
            }
            if (pa is IOrientation)
            {
                orientation = pa as IOrientation;
            }
            else
            {
                orientation = null;
            }
            if (pa is IAngularVelocity)
            {
                om = pa as IAngularVelocity;
            }
            else
            {
                om = null;
            }
        }