PolarAccData.cs 964 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using Valve.VR.InteractionSystem;
  6. public class AccData
  7. {
  8. private long timestamp;
  9. private List<Vector3> values;
  10. public long Timestamp => timestamp;
  11. public List<Vector3> Values => values;
  12. AccData(long timestamp, List<Vector3> values)
  13. {
  14. this.timestamp = timestamp;
  15. this.values = values;
  16. }
  17. public static AccData fromString(string s)
  18. {
  19. var data = s.Split(';');
  20. if (data.Length == 2)
  21. {
  22. var t = long.Parse(data[0]);
  23. var tupleStrings = data[1].Split(',').Select(item => item.Replace("(", "").Replace(")", ""));
  24. var floats = tupleStrings.Select(s1 => s1.Split('/').Select(value => float.Parse(value)).ToList()).ToList();
  25. return new AccData(t, floats.Select(a => new Vector3(a[0], a[1], a[2])).ToList());
  26. }
  27. return null;
  28. }
  29. }