private void DrawSmoothOverlappedStep(Vector2 offset) { float r = .02f; int count = 20; float delta = 1f / count; Color[] colors = { Color.red, Color.green, Color.blue, Color.yellow, Color.magenta, Color.cyan }; float overlap = .5f; int objCount = 3; Vector2[] prev = new Vector2[objCount]; for (int k = 0; k < objCount; ++k) { prev[k] = new Vector2(0, Mathfex.EvalSmoothOverlappedStep(0f, overlap, k, objCount)); Gizmos.color = colors[k % colors.Length]; Gizmos.DrawSphere(prev[k] + offset, r); } Vector2[] curr = new Vector2[3]; for (int i = 1; i <= count; ++i) { float x = i * delta; for (int k = 0; k < objCount; ++k) { curr[k] = new Vector2(x, Mathfex.EvalSmoothOverlappedStep(x, overlap, k, objCount)); Gizmos.color = colors[k % colors.Length]; Gizmos.DrawLine(prev[k] + offset, curr[k] + offset); Gizmos.DrawSphere(curr[k] + offset, r); prev[k] = curr[k]; } } }
private void OnDrawGizmos() { Circle3 circle = new Circle3(Vector3ex.Zero, Vector3ex.UnitY, Rho); Vector3 cartesian = Mathfex.CylindricalToCartesian(new Vector3(Rho, Phi, Height)); Vector3 cylindrical = Mathfex.CartesianToCylindrical(cartesian); FiguresColor(); DrawCircle(ref circle); ResultsColor(); DrawSegment(new Vector3(cartesian.x, 0f, cartesian.z), cartesian); DrawPoint(cartesian); LogInfo("Cartesian: " + cartesian.ToStringEx() + " Cylindrical: " + cylindrical.ToStringEx()); }
private void OnDrawGizmos() { Circle2 circle = new Circle2(Vector2ex.Zero, Rho); Vector2 cartesian = Mathfex.PolarToCartesian(new Vector2(Rho, Phi)); Vector2 polar = Mathfex.CartesianToPolar(cartesian); FiguresColor(); DrawCircle(ref circle); ResultsColor(); DrawSegment(Vector2ex.Zero, cartesian); DrawPoint(cartesian); LogInfo("Cartesian: " + cartesian.ToStringEx() + " Polar: " + polar.ToStringEx()); }
private void OnDrawGizmos() { Sphere3 sphere = new Sphere3(Vector3ex.Zero, Rho); Vector3 cartesian = Mathfex.SphericalToCartesian(new Vector3(Rho, Theta, Phi)); Vector3 spherical = Mathfex.CartesianToSpherical(cartesian); FiguresColor(); DrawSphere(ref sphere); ResultsColor(); DrawSegment(Vector3ex.Zero, cartesian); DrawPoint(cartesian); LogInfo("Cartesian: " + cartesian.ToStringEx() + " Spherical: " + spherical.ToStringEx()); }
private float EvalInOut(float value, InOutTypes type) { switch (type) { default: case InOutTypes.Linear: return(value); case InOutTypes.Squared: return(Mathfex.EvalSquared(value)); case InOutTypes.Cubic: return(Mathfex.EvalCubic(value)); case InOutTypes.InvSquared: return(Mathfex.EvalInvSquared(value)); case InOutTypes.InvCubic: return(Mathfex.EvalInvCubic(value)); } }
private void DrawGaussian(Vector2 offset) { float r = .02f; int count = 20; float delta = 2f / count; Gizmos.color = Color.white; Vector2 prev = new Vector2(-count * delta, Mathfex.EvalGaussian(-count * delta, 1.5f, 0f, .5f)); Gizmos.DrawSphere(prev + offset, r); Vector2 curr; for (int i = -count + 1; i <= count; ++i) { float x = i * delta; curr = new Vector2(x, Mathfex.EvalGaussian(x, 1.5f, 0f, .5f)); Gizmos.DrawLine(prev + offset, curr + offset); Gizmos.DrawSphere(curr + offset, r); prev = curr; } }
private void DrawSigmoid(Vector2 offset) { float r = .02f; int count = 20; float delta = 1f / count; Gizmos.color = Color.white; Vector2 prev = new Vector2(0, Mathfex.EvalSigmoid(0f)); Gizmos.DrawSphere(prev + offset, r); Vector2 curr; for (int i = 1; i <= count; ++i) { float x = i * delta; curr = new Vector2(x, Mathfex.EvalSigmoid(x)); Gizmos.DrawLine(prev + offset, curr + offset); Gizmos.DrawSphere(curr + offset, r); prev = curr; } }
private void Update() { float halfTime = Time * .5f; if (_timer < halfTime) { float coeff = _timer / halfTime; for (int i = 0; i < AnimatedObjects.Length; ++i) { float itemCoeff = Mathfex.EvalOverlappedStep(coeff, Overlap, i, AnimatedObjects.Length); itemCoeff = EvalInOut(itemCoeff, LeftType); float coord = Mathf.Lerp(Left, Middle, itemCoeff); Vector3 position = AnimatedObjects[i].position; position.x = coord; AnimatedObjects[i].position = position; } } else { float coeff = (_timer - halfTime) / halfTime; for (int i = 0; i < AnimatedObjects.Length; ++i) { float itemCoeff = Mathfex.EvalOverlappedStep(coeff, Overlap, i, AnimatedObjects.Length); itemCoeff = EvalInOut(itemCoeff, RightType); float coord = Mathf.Lerp(Middle, Right, itemCoeff); Vector3 position = AnimatedObjects[i].position; position.x = coord; AnimatedObjects[i].position = position; } } _timer += UnityEngine.Time.deltaTime; if (_timer > Time) { _timer -= Time; } }
private void OnDrawGizmos() { System.Func <float, float, float, float> method = null; switch (Type) { case Types.Lerp: method = Mathfex.Lerp; break; case Types.Sigerp: method = Mathfex.SigmoidInterp; break; case Types.Sinerp: method = Mathfex.SinInterp; break; case Types.Coserp: method = Mathfex.CosInterp; break; case Types.Berp: method = Mathfex.WobbleInterp; break; case Types.Curverp: method = delegate(float v0, float v1, float factor) { return(Mathfex.CurveInterp(v0, v1, factor, Curve)); }; break; case Types.Funcerp: method = delegate(float v0, float v1, float factor) { return(Mathfex.FuncInterp(v0, v1, factor, Func)); }; break; } float t = _timer / Time; Vector2 v; v.x = method(From.x, To.x, t); v.y = method(From.y, To.y, t); Gizmos.color = Color.blue; Gizmos.DrawSphere(From, .5f); Gizmos.DrawSphere(To, .5f); Gizmos.color = Color.white; Gizmos.DrawSphere(v, .25f); }