using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace TrackerBridge { public struct GazeData { public readonly float leftX; public readonly float leftY; public readonly float rightX; public readonly float rightY; public readonly long trackerTimeStamp; public readonly long systemTimeStamp; public GazeData(float leftX, float leftY, float rightX, float rightY, long trackerTimeStamp, long systemTimeStamp) { this.leftX = leftX; this.leftY = leftY; this.rightX = rightX; this.rightY = rightY; this.trackerTimeStamp = trackerTimeStamp; this.systemTimeStamp = systemTimeStamp; } public override string ToString() { FormattableString message = $"{leftX};{leftY};{rightX};{rightY};{trackerTimeStamp};{systemTimeStamp}"; return FormattableString.Invariant(message); } public static GazeData operator +(GazeData a, GazeData b) { GazeData result = new GazeData(a.leftX + b.leftX, a.leftY + b.leftY, a.rightX + b.rightX, a.rightY + b.rightY, Math.Abs(a.trackerTimeStamp - b.trackerTimeStamp), Math.Abs(a.systemTimeStamp - b.systemTimeStamp)); return result; } public static GazeData operator -(GazeData a, GazeData b) { GazeData result = new GazeData(a.leftX - b.leftX, a.leftY - b.leftY, a.rightX - b.rightX, a.rightY - b.rightY, Math.Abs(a.trackerTimeStamp - b.trackerTimeStamp), Math.Abs(a.systemTimeStamp - b.systemTimeStamp)); return result; } public static GazeData operator /(GazeData a, Single b) { GazeData result = new GazeData(a.leftX / b, a.leftY / b, a.rightX / b, a.rightY / b, a.trackerTimeStamp / Convert.ToInt64(b), a.systemTimeStamp / Convert.ToInt64(b)); return result; } } }