public Vector3D?GetTorque(ChaseOrientation_GetTorqueArgs e) { Vector3D unit; double length; GetDesiredVector(out unit, out length, e, this.Direction); if (Math3D.IsNearZero(unit)) { return(null); } double torque = this.Value; if (this.IsAccel) { // f=ma torque *= e.ItemMass; } if (this.IsSpring) { torque *= e.Rotation.Angle; } if (this.IsDrag) { torque *= -length; // negative, because it needs to be a drag force } // Gradient % if (this.Gradient != null) { torque *= ChasePoint_Force.GetGradientPercent(e.Rotation.Angle, this.Gradient); } return(unit * torque); }
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 }; }