Пример #1
0
        public PosXYZ Scale(PosXYZ scaleFactor)
        {
            var p = new PosXYZ();

            p.Index       = p.Index;
            p.Name        = p.Name;
            p.Description = p.Description;
            p.X           = scaleFactor.X * X;
            p.Y           = scaleFactor.Y * Y;
            p.Z           = scaleFactor.Z * Z;
            return(p);
        }
Пример #2
0
        public PosXYZ Translate(PosXYZ offset)
        {
            var p = new PosXYZ();

            p.Index       = p.Index;
            p.Name        = p.Name;
            p.Description = p.Description;
            p.X           = offset.X + X;
            p.Y           = offset.Y + Y;
            p.Z           = offset.Z + Z;
            return(p);
        }
Пример #3
0
        public void LoadPts(string file)
        {
            using (var fs = new FileStream(file, FileMode.Open))
            {
                using (var sr = new StreamReader(fs))
                {
                    //find platform pos start line
                    var line = sr.ReadLine();
                    if (line != null && line.StartsWith(Name))
                    {
                        var propCount = PosType.GetProperties().Length;

                        //start read pos lines
                        line = sr.ReadLine();
                        while (!string.IsNullOrEmpty(line))
                        {
                            var data = line.Split(',');
                            if (data.Length == propCount)
                            {
                                if (PosType == typeof(PosXYZ))
                                {
                                    Positions.Add(PosXYZ.Create(line));
                                }
                                else if (PosType == typeof(PosXYZU))
                                {
                                    Positions.Add(PosXYZU.Create(line));
                                }
                                else if (PosType == typeof(PosXYZUVW))
                                {
                                    Positions.Add(PosXYZUVW.Create(line));
                                }
                                else
                                {
                                    //pos type error
                                }
                            }
                            else
                            {
                                //pos prop length error
                                MessageBox.Show($"{line} Props Count Error");
                            }

                            line = sr.ReadLine();
                        }
                    }
                }
            }
        }
        public override void TeachPos(string name)
        {
            var curpos = new PosXYZ(CurPos);

            if (Positions.Exists(p => p.Name == name))
            {
                var teachpos = Positions.FirstOrDefault(p => p.Name == name);
                teachpos?.Update(curpos.Data());
            }
            else
            {
                curpos.Name = name;

                Positions.Add(curpos);
            }
        }
Пример #5
0
        /// <summary>
        /// 2d rotation
        /// </summary>
        /// <param name="center"></param>
        /// <param name="angle"></param>
        /// <returns></returns>
        public PosXYZ RotateAt(PosXYZ center, double angle)
        {
            var dx    = X - center.X;
            var dy    = Y - center.Y;
            var theta = angle / 360 * Math.PI;

            var rotDx = Math.Cos(theta) * dx - Math.Sin(theta) * dy;
            var rotDy = Math.Sin(theta) * dx + Math.Cos(theta) * dy;

            var p = new PosXYZ();

            p.X = center.X + rotDx;
            p.Y = center.Y + rotDy;
            p.Z = Z;
            return(p);
        }
Пример #6
0
        public static PosXYZ Create(string posStr)
        {
            var data = posStr.Split(',');

            int i = 0;
            var p = new PosXYZ();

            p.Index       = int.Parse(data[i++]);
            p.Name        = data[i++];
            p.X           = double.Parse(data[i++]);
            p.Y           = double.Parse(data[i++]);
            p.Z           = double.Parse(data[i++]);
            p.OffsetX     = double.Parse(data[i++]);
            p.OffsetY     = double.Parse(data[i++]);
            p.OffsetZ     = double.Parse(data[i++]);
            p.Status      = bool.Parse(data[i++]);
            p.Description = data[i++];
            p.Flag1       = int.Parse(data[i++]);
            p.Flag2       = int.Parse(data[i++]);
            p.Flag3       = int.Parse(data[i++]);

            return(p);
        }