/// <summary> /// Figures out what the differences between this animation frame and the given one are, /// and returns those differences. /// To visualize it, "this" frame is now, "other" frame is the next time step. /// Thus, any elements in "this" that's not in "other" can be ignored, elements in "other" not in "this" are required, /// and elements in both are required if they change from "this" to "other". /// </summary> /// <param name="other">The other animation frame to look at</param> /// <returns>The differences between this and other</returns> public AnimationFrame delta(AnimationFrame other, double RotationEpsilon = 0.001, double PositionEpsilon = 0.5) { SortedList<int, Tuple<Vector3D, Quaternion>> ret = new SortedList<int, Tuple<Vector3D, Quaternion>>(); foreach (var kv in other.Blocks) { if (this.Blocks.ContainsKey(kv.Key)) { Vector3D posdiff = (this.Blocks[kv.Key].Item1 - kv.Value.Item1).Abs(); //I'm not sure if this will work - I don't know if they implement special //quaternion-specific subtraction routines. Quaternion rotdiff = (this.Blocks[kv.Key].Item2 - kv.Value.Item2).Abs(); if (posdiff.X > PositionEpsilon || posdiff.Y > PositionEpsilon || posdiff.Z > PositionEpsilon) { ret.Add(kv.Key, kv.Value); } else if (rotdiff.W > RotationEpsilon || rotdiff.X > RotationEpsilon || rotdiff.Y > RotationEpsilon || rotdiff.Z > RotationEpsilon) { ret.Add(kv.Key, kv.Value); } } else { ret.Add(kv.Key, kv.Value); } } return new AnimationFrame(ret); }
public void AddFrame(AnimationFrame a) { _anim.Add(a); }