public float[] GetContacts(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseContacts[index] == null) { PrecomputedInverseContacts[index] = new Precomputable <float[]>(Compute()); } if (!mirrored && PrecomputedRegularContacts[index] == null) { PrecomputedRegularContacts[index] = new Precomputable <float[]>(Compute()); } return(mirrored ? PrecomputedInverseContacts[index].Value : PrecomputedRegularContacts[index].Value); } return(Compute()); float[] Compute() { float[] contacts = new float[Sensors.Length]; for (int i = 0; i < Sensors.Length; i++) { contacts[i] = Sensors[i].GetContact(timestamp, mirrored); } return(contacts); } }
public Quaternion GetRootRotation(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseRotations[index] == null) { PrecomputedInverseRotations[index] = new Precomputable <Quaternion>(Compute()); } if (!mirrored && PrecomputedRegularRotations[index] == null) { PrecomputedRegularRotations[index] = new Precomputable <Quaternion>(Compute()); } return(mirrored ? PrecomputedInverseRotations[index].Value : PrecomputedRegularRotations[index].Value); } return(Compute()); Quaternion Compute() { if (!Smooth) { return(RootRotation(timestamp, mirrored)); } SamplingWindow = SamplingWindow == null?Data.GetTimeWindow(MotionEditor.GetInstance().PastWindow + MotionEditor.GetInstance().FutureWindow, 1f) : SamplingWindow; TmpRotations = TmpRotations.Validate(SamplingWindow.Length); TmpAngles = TmpAngles.Validate(TmpRotations.Length - 1); for (int i = 0; i < SamplingWindow.Length; i++) { TmpRotations[i] = RootRotation(timestamp + SamplingWindow[i], mirrored); } for (int i = 0; i < TmpAngles.Length; i++) { TmpAngles[i] = Vector3.SignedAngle(TmpRotations[i].GetForward(), TmpRotations[i + 1].GetForward(), Vector3.up) / (SamplingWindow[i + 1] - SamplingWindow[i]); } float power = Mathf.Deg2Rad * Mathf.Abs(TmpAngles.Gaussian()); return(TmpRotations.Gaussian(power)); } }
public Vector3 GetBallPivot(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInversePivots[index] == null) { PrecomputedInversePivots[index] = new Precomputable <Vector3>(Compute()); } if (!mirrored && PrecomputedRegularPivots[index] == null) { PrecomputedRegularPivots[index] = new Precomputable <Vector3>(Compute()); } return(mirrored ? PrecomputedInversePivots[index].Value : PrecomputedRegularPivots[index].Value); } return(Compute()); Vector3 Compute() { SmoothingWindow = SmoothingWindow == null?Data.GetTimeWindow(MotionEditor.GetInstance().PastWindow + MotionEditor.GetInstance().FutureWindow, 1f) : SmoothingWindow; SmoothingVectors = SmoothingVectors.Validate(SmoothingWindow.Length); SmoothingAngles = SmoothingAngles.Validate(SmoothingVectors.Length - 1); for (int i = 0; i < SmoothingVectors.Length; i++) { SmoothingVectors[i] = (GetBallPosition(timestamp + SmoothingWindow[i], mirrored).GetRelativePositionTo(GetRoot(timestamp + SmoothingWindow[i], mirrored))).ZeroY().normalized; } for (int i = 0; i < SmoothingAngles.Length; i++) { SmoothingAngles[i] = Vector3.SignedAngle(SmoothingVectors[i], SmoothingVectors[i + 1], Vector3.up) / (SmoothingWindow[i + 1] - SmoothingWindow[i]); } float power = Mathf.Deg2Rad * Mathf.Abs(SmoothingAngles.Gaussian()); return(SmoothingVectors.Gaussian(power).SetY(Height(timestamp, mirrored))); } }
public Vector3 GetRootVelocity(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseVelocities[index] == null) { PrecomputedInverseVelocities[index] = new Precomputable <Vector3>(Compute()); } if (!mirrored && PrecomputedRegularVelocities[index] == null) { PrecomputedRegularVelocities[index] = new Precomputable <Vector3>(Compute()); } return(mirrored ? PrecomputedInverseVelocities[index].Value : PrecomputedRegularVelocities[index].Value); } return(Compute()); Vector3 Compute() { return((GetRootPosition(timestamp, mirrored) - GetRootPosition(timestamp - Data.GetDeltaTime(), mirrored)) / Data.GetDeltaTime()); } }
public Matrix4x4 GetRootTransformation(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseTransformations[index] == null) { PrecomputedInverseTransformations[index] = new Precomputable <Matrix4x4>(Compute()); } if (!mirrored && PrecomputedRegularTransformations[index] == null) { PrecomputedRegularTransformations[index] = new Precomputable <Matrix4x4>(Compute()); } return(mirrored ? PrecomputedInverseTransformations[index].Value : PrecomputedRegularTransformations[index].Value); } return(Compute()); Matrix4x4 Compute() { return(Matrix4x4.TRS(GetRootPosition(timestamp, mirrored), GetRootRotation(timestamp, mirrored), Vector3.one)); } }
public Vector3 GetBallMomentum(float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseMomentums[index] == null) { PrecomputedInverseMomentums[index] = new Precomputable <Vector3>(Compute()); } if (!mirrored && PrecomputedRegularMomentums[index] == null) { PrecomputedRegularMomentums[index] = new Precomputable <Vector3>(Compute()); } return(mirrored ? PrecomputedInverseMomentums[index].Value : PrecomputedRegularMomentums[index].Value); } return(Compute()); Vector3 Compute() { return(((GetBallPivot(timestamp, mirrored) - GetBallPivot(timestamp - Data.GetDeltaTime(), mirrored)) / Data.GetDeltaTime()).SetY(Speed(timestamp, mirrored))); } }
public ComponentSeries ExtractSeries(TimeSeries global, float timestamp, bool mirrored) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (mirrored && PrecomputedInverseComponentSeries[index] == null) { PrecomputedInverseComponentSeries[index] = new Precomputable <ComponentSeries>(Compute()); } if (!mirrored && PrecomputedRegularComponentSeries[index] == null) { PrecomputedRegularComponentSeries[index] = new Precomputable <ComponentSeries>(Compute()); } return(mirrored ? PrecomputedInverseComponentSeries[index].Value : PrecomputedRegularComponentSeries[index].Value); } return(Compute()); ComponentSeries Compute() { return(DerivedExtractSeries(global, timestamp, mirrored)); } }
public float[] GetValues(float timestamp) { if (Data.IsPrecomputable(timestamp)) { int index = Data.GetPrecomputedIndex(timestamp); if (PrecomputedStyles[index] == null) { PrecomputedStyles[index] = new Precomputable <float[]>(Compute()); } return(PrecomputedStyles[index].Value); } return(Compute()); float[] Compute() { float[] style = new float[Functions.Length]; for (int i = 0; i < Functions.Length; i++) { style[i] = GetStyle(timestamp, i); } return(style); } }