public AngleBasedHandModel() { rotation = new sQuaternion(); position = new sVector3(0, 0, 0); thumb = new AngleBasedThumbModel(); for (int i = 0; i < fingers.Length; i++) { fingers[i] = new AngleBasedFingerModel(); } }
public float euclidianDistance(AngleBasedThumbModel other) { float result = 0; for (int i = 0; i < jointAngles.Length - 3; i++) { result += Mathf.Pow(jointAngles [i] - other.jointAngles [i], 2.0f); } result += Mathf.Pow(Quaternion.Angle(other.tmc, tmc), 2.0f); return(Mathf.Sqrt(result)); }
public static AngleBasedThumbModel Lerp(AngleBasedThumbModel first, AngleBasedThumbModel second, float t) { AngleBasedThumbModel result = new AngleBasedThumbModel(); t = Mathf.Clamp(t, 0, 1); result.tmc = Quaternion.Lerp(first.tmc, second.tmc, t); for (int i = 0; i < result.jointAngles.Length; i++) { result.jointAngles [i] = Mathf.Lerp(first.jointAngles [i], second.jointAngles [i], t); } return(result); }
public static string getCSVHeader(string endl, string handname) { string result = ""; result += AngleBasedThumbModel.getCSVHeader(endl, handname + "Thumb") + endl; for (int i = 0; i < System.Enum.GetNames(typeof(FingerName)).Length; i++) { result += AngleBasedFingerModel.getCSVHeader(endl, handname + System.Enum.GetNames(typeof(FingerName))[i]) + endl; } result += sQuaternion.getCSVHeader(endl, handname + "Rot") + endl; result += sVector3.getCSVHeader(endl, handname + "Pos"); return(result); }
public static AngleBasedHandModel Lerp(AngleBasedHandModel first, AngleBasedHandModel second, float t) { AngleBasedHandModel result = new AngleBasedHandModel(); t = Mathf.Clamp(t, 0, 1); result.rotation = Quaternion.Lerp(first.rotation, second.rotation, t); result.position = Vector3.Lerp(first.position, second.position, t); for (int i = 0; i < result.fingers.Length; i++) { result.fingers [i] = AngleBasedFingerModel.Lerp(first.fingers [i], second.fingers [i], t); } result.thumb = AngleBasedThumbModel.Lerp(first.thumb, second.thumb, t); return(result); }