1234567891011121314151617181920212223242526272829303132333435 |
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using UnityEngine;
- using Valve.VR.InteractionSystem;
- public class AccData
- {
- private long timestamp;
- private List<Vector3> values;
- public long Timestamp => timestamp;
- public List<Vector3> Values => values;
- 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());
- }
- return null;
- }
- }
|