RubberBandCalculator[] CreateRubberBandCalculator() { RubberBandCalculator[] result = new RubberBandCalculator[2]; thisRubberLimit = new Vector2(); for (int i = 0; i < 2; i++) { float rubberLimit = thisRubberBandLimitMultiplier[i] * GetRectSize()[i]; thisRubberLimit[i] = rubberLimit; result[i] = new RubberBandCalculator(1f, rubberLimit); } return(result); }
public void CalcRubberBandValue_Demo(float suppleness, float limitLength) { IRubberBandCalculator calculator = new RubberBandCalculator(suppleness, limitLength); float origDisp = 0f; int stepSize = Mathf.RoundToInt(limitLength); float prev = 0f; float diffThreshold = 0.5f; float rubberBandedValue = 0f; int iteration = 0; DebugHelper.PrintInRed("suppleness: " + suppleness.ToString() + ", limitLength: " + limitLength.ToString()); while (rubberBandedValue + diffThreshold < limitLength) { rubberBandedValue = calculator.CalcRubberBandValue(origDisp, false); float delta = rubberBandedValue - prev; Debug.Log("iteration: " + iteration.ToString() + ", origDisp: " + origDisp.ToString() + ", rubberValue: " + rubberBandedValue.ToString() + ", delta: " + delta.ToString()); prev = rubberBandedValue; origDisp += stepSize; iteration++; } }