| | |
| | | return data.TrimEnd(new char[] { ',' }); |
| | | } |
| | | } |
| | | |
| | | public class RobotPoint : IComplexDisplay |
| | | { |
| | | [Category("点位信息")] |
| | | [Description("坐标X")] |
| | | public float X { get; set; } |
| | | |
| | | [Category("点位信息")] |
| | | [Description("坐标Y")] |
| | | public float Y { get; set; } |
| | | |
| | | [Category("点位信息")] |
| | | [Description("坐标Z")] |
| | | public float Z { get; set; } |
| | | |
| | | [Category("点位信息")] |
| | | [Description("角度A")] |
| | | public float A { get; set; } |
| | | |
| | | [Category("点位信息")] |
| | | [Description("角度B")] |
| | | public float B { get; set; } |
| | | |
| | | [Category("点位信息")] |
| | | [Description("角度C")] |
| | | public float C { get; set; } |
| | | |
| | | public string GetDisplayText() |
| | | { |
| | | return $"X:{X.ToString()} Y:{Y.ToString()} Z:{Z.ToString()} A:{A.ToString()} B:{B.ToString()} C:{C.ToString()}"; |
| | | } |
| | | |
| | | public double[] GetArray() |
| | | { |
| | | return new double[] { X, Y, Z, A, B, C }; |
| | | } |
| | | |
| | | public static RobotPoint GetRobotPointByArray(double[] array) |
| | | { |
| | | if (array.Length != 6) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | RobotPoint point = new RobotPoint(); |
| | | point.X = (float)array[0]; |
| | | point.Y = (float)array[1]; |
| | | point.Z = (float)array[2]; |
| | | point.A = (float)array[3]; |
| | | point.B = (float)array[4]; |
| | | point.C = (float)array[5]; |
| | | |
| | | return point; |
| | | } |
| | | |
| | | public static float GetDistance(RobotPoint pointA, RobotPoint pointB) |
| | | { |
| | | return (float)Math.Sqrt(Math.Pow(pointA.X - pointB.X, 2) + Math.Pow(pointA.Y - pointB.Y, 2) + Math.Pow(pointA.Z - pointB.Z, 2)); |
| | | } |
| | | } |
| | | } |