public MapObject_ChasePoint_Forces GetChaseObject_Linear(IMapObject item) { if (!_isLinear) { throw new InvalidOperationException("This method can only be called when the control represents linear"); } MapObject_ChasePoint_Forces retVal = new MapObject_ChasePoint_Forces(item, false); //TODO: May want to expose these. I think they're unnecessary, and the result of overdesign //retVal.MaxAcceleration = //retVal.MaxForce = List <ChasePoint_Force> forces = new List <ChasePoint_Force>(); foreach (UIElement entry in pnlForces.Children) { ChasePoint_Force chaseObject = null; if (entry is ForceEntry) { chaseObject = ((ForceEntry)entry).GetChaseObject_Linear(); } else { throw new ApplicationException("Unknown type of entry: " + entry.ToString()); } //NOTE: Doing a null check, because if they uncheck enabled, it will come back null if (chaseObject != null) { forces.Add(chaseObject); } } if (forces.Count > 0) { retVal.Forces = forces.ToArray(); return(retVal); } else { // Don't bother returning something that will fail on update return(null); } }
private static ChasePoint_Force[] GetRepelInitialForces(double powerMult = 1, double distMult = 1) { //Tuple<double,double>[] gradient = GetDropoffGradient(5, 10, 1); Tuple<double, double>[] gradient = new[] { Tuple.Create(0d, 1d), Tuple.Create(10d * distMult, 0d), }; ChasePoint_Force repel = new ChasePoint_Force(ChaseDirectionType.Attract_Direction, ACCEL * -3 * powerMult, gradient: gradient); gradient = new[] { Tuple.Create(0d, 1d), Tuple.Create(1.5 * distMult, .7d), Tuple.Create(3d * distMult, 0d), }; ChasePoint_Force tooCloseAndHotFriction = new ChasePoint_Force(ChaseDirectionType.Drag_Velocity_AlongIfVelocityToward, ACCEL * 4 * powerMult, gradient: gradient); return new[] { repel, tooCloseAndHotFriction }; }