// V^2 = u^2 + 2as public static void RanOn_11010(Particle values, int i) { float insideRoot = Mathf.Pow(values.InitialVelociy[i], 2) + (2 * values.Acceleration[i] * values.Displacement[i]); if (insideRoot < 0) { values.inValidInput[i] = true; } else { values.FinalVelocity[i] = MyMaths.SquareRoot(insideRoot); //Checking direction which is lost by squaring if (values.Acceleration[i] < 0 && values.Displacement[i] <= 0) { values.FinalVelocity[i] = -values.FinalVelocity[i]; } values.Key[i] = ReplaceAtIndex(2, '1', values.Key[i]); } }
// V^2 = u^2 + 2as public static void RanOn_11010(newParticle values, int dimention) { float insideRoot = Mathf.Pow(values.initialVelocity[dimention], 2) + (2 * values.acceleration[dimention] * values.displacement[dimention]); //Square root must be positive.Therefore invalid input if not true if (insideRoot < 0) { values.invalidInputs[dimention] = true; } else { Vector3 temp = values.currentVelocity; temp[dimention] = MyMaths.SquareRoot(insideRoot); values.currentVelocity = temp; //Checking direction which is lost by squaring if (values.acceleration[dimention] < 0 && values.displacement[dimention] <= 0) { temp[dimention] = -values.currentVelocity[dimention]; values.currentVelocity = temp; } values.key[dimention] = ReplaceAtIndex(2, '1', values.key[dimention]); } }