using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using HalconDotNet; namespace DataStruct { public class DataStruct { /// /// XYU结果 /// [Serializable] public class PosXYU { public double X; public double Y; public double U; /// /// 将XYU类型转化成格式化字符串 /// /// internal string ToFormatStr() { return (X >= 0 ? "+" + X.ToString("0000.000") : X.ToString("0000.000")) + "," + (Y >= 0 ? "+" + Y.ToString("0000.000") : Y.ToString("0000.000")) + "," + (U >= 0 ? "+" + U.ToString("0000.000") : U.ToString("0000.000")); } internal string ToShowTip() { return X.ToString() + " | " + Y.ToString() + " | " + U.ToString(); } } [Serializable] public class Line { public Point StartPoint; public Point EndPoint; internal string ToShowTip() { return StartPoint.Row.ToString() + " | " + StartPoint.Col.ToString() + " | " + EndPoint.Row.ToString() + " | " + EndPoint.Col.ToString(); } private HTuple _angle; public double Angle { get { HOperatorSet.AngleLx(StartPoint.Row, StartPoint.Col, EndPoint.Row, EndPoint.Col, out _angle); return _angle; } } } [Serializable] public class Point { public Point() { } public Point(double x, double y) { this.Row = x; this.Col = y; } public double Row; public double Col; /// /// 重写 - /// /// 点1 /// 点2 /// public static Point operator -(Point p1, Point p2) { return new Point(p1.Row - p2.Row, p1.Col - p2.Col); } /// /// 获得点矢量长度 /// public double GetDistance { get { return Math.Sqrt(Row * Row + Col * Col); } } public string ToShowTip() { return Row.ToString() + " | " + Col.ToString(); } } } }