public void tuneTf(Vector3d torque) { Vector3d ratio = new Vector3d( torque.x != 0 ? vesselState.MoI.x / torque.x : 0, torque.y != 0 ? vesselState.MoI.y / torque.y : 0, torque.z != 0 ? vesselState.MoI.z / torque.z : 0 ); TfV = 0.05 * ratio; //print("TfV O " + MuUtils.PrettyPrint(TfV)); Vector3d delayFactor = Vector3d.one + 2 * vesselState.torqueReactionSpeed; //print("del F " + MuUtils.PrettyPrint(delayFactor)); TfV.Scale(delayFactor); TfV = TfV.Clamp(2.0 * TimeWarp.fixedDeltaTime, TfMax); TfV = TfV.Clamp(TfMin, TfMax); //print("TfV F " + MuUtils.PrettyPrint(TfV)); //Tf = Mathf.Clamp((float)ratio.magnitude / 20f, 2 * TimeWarp.fixedDeltaTime, 1f); //Tf = Mathf.Clamp((float)Tf, (float)TfMin, (float)TfMax); }
public void Clamp() { Vector3d v = new Vector3d(0.4f, 1.6f, 0.1f); v.Clamp(0.5f, 1.5f); Assert.AreEqual(v, new Vector3d(0.5f, 1.5f, 0.5f)); v = new Vector3d(0.4f, 1.6f, 0.1f); v.Clamp(new Vector3d(0.5f, 1.5f, 0.5f), new Vector3d(0.5f, 1.5f, 0.5f)); Assert.AreEqual(v, new Vector3d(0.5f, 1.5f, 0.5f)); }
public void tuneTf(Vector3d torque) { Vector3d ratio = new Vector3d( torque.x != 0 ? vesselState.MoI.x / torque.x : 0, torque.z != 0 ? vesselState.MoI.z / torque.z : 0, //y <=> z torque.y != 0 ? vesselState.MoI.y / torque.y : 0 //z <=> y ); TfV = 0.05 * ratio; Vector3d delayFactor = Vector3d.one + 2 * vesselState.torqueReactionSpeed; TfV.Scale(delayFactor); TfV = TfV.Clamp(2.0 * TimeWarp.fixedDeltaTime, 1.0); TfV = TfV.Clamp(TfMin, TfMax); //Tf = Mathf.Clamp((float)ratio.magnitude / 20f, 2 * TimeWarp.fixedDeltaTime, 1f); //Tf = Mathf.Clamp((float)Tf, (float)TfMin, (float)TfMax); }
/// <summary>Get the nearest point between this <see cref="Box3d"/> and a <see cref="Vector3d"/>. If the <see cref="Vector3d"/> is inside this <see cref="Box3d"/>, it is returned untouched.</summary> public void NearestPointTo( ref Vector3d point , out Vector3d result) { Containment containment = Intersect(ref point); if(containment != Containment.Disjoint) result = point; else point.Clamp(ref Min, ref Max, out result); return; }