using System; using System.Collections.Generic; using System.Text; using SalsaModel.Scheduling; namespace SalsaModel.Actions { class HeelMoverAction : IAction { public static void AddTo(TimeLine timeLine, double start, double duration, SalsaMover mover, PositionModel.Side side) { timeLine.Add(start, duration, new HeelMoverAction(mover, side)); } public readonly SalsaMover Mover; public readonly PositionModel.Side Side; double _fromFootZ; double _toFootZ; double _toFootInitZ; public HeelMoverAction(SalsaMover mover, PositionModel.Side side) { Mover = mover; Side = PositionModel.Other(side); } public void Start() { _fromFootZ = Mover.Model.GetLeg(Side).Foot.Z; _toFootInitZ = Mover.Model.GetOtherLeg(Side).Foot.Z; _toFootZ = Mover.Body.Foot / 1.5; } public void Update(double percent) { const double heelMovingTime = 1.0; double fromFootNewZ = _fromFootZ * Math.Min((1.0 - percent) / heelMovingTime, 1.0); double toFootNewZ = (_toFootZ - _toFootInitZ) * Math.Min(percent / heelMovingTime, 1.0) + _toFootInitZ; Mover.Model.GetLeg(Side).Foot = Mover.Model.GetLeg(Side).Foot.SetZ(fromFootNewZ); Mover.Model.GetOtherLeg(Side).Foot = Mover.Model.GetOtherLeg(Side).Foot.SetZ(toFootNewZ); } public void End() { } public string DescriptiveCode { get { return PositionModel.SideCode(Side) + "Heel"; } } } }