public static void Basic() { Assert.AreEqual(FXY(x => 3f)(5f), 3f); Assert.AreEqual(FXY(x => Linear(ExC(6f), ExC(2f), x.FloatVal))(5f), 16f); var f = FXY(x => Cos(x.FloatVal)); Debug.Log(f(Mathf.PI)); Debug.Log(f(0)); Debug.Log(f(Mathf.PI * 2f)); f = FXY(t => SubMax0(t.FloatVal, Expression.Constant(4f))); AreEqual(f(3), 0); AreEqual(f(-3), 0); AreEqual(f(5), 1); }
private IEnumerator IShake(float time, FXY magnitude, float magMul, ICancellee cT, Action?done) { Vector3 pp = tr.localPosition; // Should be (0, 0, ?) for (float elapsed = 0; elapsed < time;) { float m = magnitude(elapsed) * magMul * ScreenshakeMultiplier * SaveData.s.Screenshake; float deg = RNG.GetFloatOffFrame(0, 360); Vector2 quake = M.PolarToXY(m, deg); tr.localPosition = pp + (Vector3)quake; yield return(null); if (cT.Cancelled) { break; } elapsed += ETime.FRAME_TIME; yield return(null); if (cT.Cancelled) { break; } elapsed += ETime.FRAME_TIME; } //Future: If you want to move the camera, do so by moving the Camera Container object. tr.localPosition = pp; done?.Invoke(); }
/// <summary> /// A combination of TM with a fixed times count, and inverse mod parametrization. /// </summary> /// <param name="times">Times count</param> /// <returns></returns> public static GenCtxProperty TMIMod(FXY times) { var t = (int)times(0); return(new CompositeProp(new TimesProp(t, _ => t), new ParametrizationProp(Parametrization.INVMOD, null))); }
public static void Softmax() { FXY fsoftmax1 = "softmax 1 { (+ 2 t) (8) }".Into <FXY>(); Assert.AreEqual(softmax(1f, new[] { 5f, 8f }), 7.85772238f, err); Assert.AreEqual(softmax(1f, new[] { 5f, 8f }), fsoftmax1(3f), err); Assert.AreEqual(softmax(1f, new[] { 9f, 8f }), fsoftmax1(7f), err); }
private void Awake() { tr = transform; baseLoc = (Vector2)tr.localPosition - (uiParent.autoShiftCamera ? GameManagement.References.bounds.center : Vector2.zero); InLerp = inLerp.Into <FXY>(); OutLerp = outLerp.Into <FXY>(); Hide(); }
private void Awake() { tr = transform; burstScale = ReflWrap <FXY> .Wrap(burstScaler); var em = particlePrefab.GetComponent <ParticleSystem>().emission; baseBurst = em.GetBurst(0); }
public static void ShiftSoftmax() { FXY eq1 = x => 5 * x; FXY eq2 = x => 2 * x; FXY shifter = FXY(SoftmaxShift(x => - 1f, x => 10f, x => Mul <float>(x.FloatVal, 5f), x => Mul <float>(x.FloatVal, 2f))); Assert.AreEqual(shiftsoftmax(-1f, 10f, eq1, eq2, 110f), 250f, 1f); Assert.AreEqual(shiftsoftmax(-1f, 10f, eq1, eq2, 10.2f), shifter(10.2f), err); Assert.AreEqual(shiftsoftmax(-1f, 10f, eq1, eq2, 9.3f), shifter(9.3f), err); }
private IEnumerator DoScale(ICancellee cT) { AssignScale(startScale); FXY e1 = ease1.Into <FXY>(); FXY e2 = ease2.Into <FXY>(); for (float t = 0; t < time1; t += ETime.FRAME_TIME) { if (cT.Cancelled) { break; } yield return(null); AssignScale(startScale + (midScale - startScale) * e1(t / time1)); } AssignScale(midScale); for (float t = 0; t < holdtime; t += ETime.FRAME_TIME) { if (cT.Cancelled) { break; } yield return(null); } for (float t = 0; t < time2; t += ETime.FRAME_TIME) { if (cT.Cancelled) { break; } yield return(null); AssignScale(midScale + (endScale - midScale) * e2(t / time2)); } AssignScale(endScale); if (destroyOnDone) { Destroy(gameObject); } }
private static void TestTPoints(FXY f, params (float t, float val)[] pts)
private static float shiftsoftmax(float sharpness, float pivot, FXY eq1, FXY eq2, float x) { return(softmax(sharpness, new[] { eq1(x), eq1(pivot) + eq2(x) - eq2(pivot) })); }
public static ExBPY PMaf(FXY self, FXY[] children) => PM((int)self(0), children.Aggregate(1, (x, y) => x * (int)y(0)));
public static ExBPY PMf(FXY self, FXY children) => PM((int)self(0), (int)children(0));
public static ExBPY P2Mf(FXY mod) => P2M((int)mod(0));
public static ExBPY P1Mf(FXY mod) => P1M((int)mod(0));