1234567891011121314151617181920212223242526272829303132 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using Valve.VR.InteractionSystem;
- public struct AccData
- {
- public long Timestamp { get; }
- public List<Vector3> Values { get; }
- AccData(long timestamp, List<Vector3> values)
- {
- this.Timestamp = timestamp;
- this.Values = values;
- }
- public static AccData FromString(string s)
- {
- var data = s.Split(';');
- if (data.Length == 2)
- {
- var t = long.Parse(data[0]);
- var tupleStrings = data[1].Split(',').Select(item => item.Replace("(", "").Replace(")", ""));
- var floats = tupleStrings.Select(s1 => s1.Split('/').Select(value => float.Parse(value)).ToList()).ToList();
- return new AccData(t, floats.Select(a => new Vector3(a[0], a[1], a[2])).ToList());
- }
- throw new FormatException("AccData String has wrong format");
- }
- }
|