Created
April 28, 2011 23:02
-
-
Save keijiro/947530 to your computer and use it in GitHub Desktop.
Revisions
-
keijiro revised this gist
Apr 28, 2011 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -55,7 +55,8 @@ public static void Out2(ref Quaternion current, Quaternion target, float coeff) public static void OutLocalTransform(Transform current, Vector3 targetPosition, Quaternion targetRotation, float coeff) { coeff = Mathf.Exp(coeff * Time.deltaTime); current.localPosition = Vector3.Lerp(targetPosition, current.localPosition, coeff); if (current.localRotation == targetRotation) { current.localRotation = targetRotation; } else { -
keijiro revised this gist
Apr 28, 2011 . 1 changed file with 48 additions and 28 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,46 +1,66 @@ // Example: // // currentPos = ExpEase.Out(currentPos, targetPos, -4.0); // // or // // ExpEase.Out2(currentPos, targetPos, -4.0); // This modifies currentPos. // using UnityEngine; public static class ExpEase { public static float Out(float current, float target, float coeff) { return target - (target - current) * Mathf.Exp(coeff * Time.deltaTime); } public static float OutAngle(float current, float target, float coeff) { return target - Mathf.DeltaAngle(current, target) * Mathf.Exp(coeff * Time.deltaTime); } public static Vector3 Out(Vector3 current, Vector3 target, float coeff) { return Vector3.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } public static Quaternion Out(Quaternion current, Quaternion target, float coeff) { if (current == target) { return target; } else { return Quaternion.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } } public static void Out2(ref float current, float target, float coeff) { current = target - (target - current) * Mathf.Exp(coeff * Time.deltaTime); } public static void OutAngle2(ref float current, float target, float coeff) { current = target - Mathf.DeltaAngle(current, target) * Mathf.Exp(coeff * Time.deltaTime); } public static void Out2(ref Vector3 current, Vector3 target, float coeff) { current = Vector3.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } public static void Out2(ref Quaternion current, Quaternion target, float coeff) { if (current == target) { current = target; } else { current = Quaternion.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } } public static void OutLocalTransform(Transform current, Vector3 targetPosition, Quaternion targetRotation, float coeff) { coeff = Mathf.Exp(coeff * Time.deltaTime); current.localPosition = Vector3.Lerp(targetPosition, current.localPosition, coeff); if (current.localRotation == targetRotation) { current.localRotation = targetRotation; } else { current.localRotation = Quaternion.Lerp(targetRotation, current.localRotation, coeff); } } } -
keijiro created this gist
Apr 28, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,46 @@ using UnityEngine; public static class ExpEase { public static float Out(float current, float target, float coeff) { return target - (target - current) * Mathf.Exp(coeff * Time.deltaTime); } public static float OutAngle(float current, float target, float coeff) { return target - Mathf.DeltaAngle(current, target) * Mathf.Exp(coeff * Time.deltaTime); } public static Vector3 Out(Vector3 current, Vector3 target, float coeff) { return Vector3.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } public static Quaternion Out(Quaternion current, Quaternion target, float coeff) { if (current == target) { return target; } else { return Quaternion.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } } public static void Out2(ref float current, float target, float coeff) { current = target - (target - current) * Mathf.Exp(coeff * Time.deltaTime); } public static void OutAngle2(ref float current, float target, float coeff) { current = target - Mathf.DeltaAngle(current, target) * Mathf.Exp(coeff * Time.deltaTime); } public static void Out2(ref Vector3 current, Vector3 target, float coeff) { current = Vector3.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } public static void Out2(ref Quaternion current, Quaternion target, float coeff) { if (current == target) { current = target; } else { current = Quaternion.Lerp(target, current, Mathf.Exp(coeff * Time.deltaTime)); } } public static void OutLocalTransform(Transform current, Vector3 targetPosition, Quaternion targetRotation, float coeff) { coeff = Mathf.Exp(coeff * Time.deltaTime); current.localPosition = Vector3.Lerp(targetPosition, current.localPosition, coeff); if (current.localRotation == targetRotation) { current.localRotation = targetRotation; } else { current.localRotation = Quaternion.Lerp(targetRotation, current.localRotation, coeff); } } }