Created
July 9, 2018 05:43
-
-
Save takopom/e2c2cc0df1885783b292cb177bac56f6 to your computer and use it in GitHub Desktop.
3点を繋ぐベジェ曲線上の座標
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 characters
| /// <summary> | |
| /// 3点を繋ぐベジェ曲線上の座標を返す | |
| /// </summary> | |
| /// <returns>座標</returns> | |
| /// <param name="start">始点</param> | |
| /// <param name="middle">中間点</param> | |
| /// <param name="end">終点</param> | |
| /// <param name="time">経過時間(0〜1)</param> | |
| public static Vector3 BezierCurveVector3(Vector3 start, Vector3 middle, Vector3 end, float time) { | |
| float invT = 1.0f - time; | |
| float powT = Mathf.Pow(time, 2.0f); | |
| float invPowT = Mathf.Pow(invT, 2.0f); | |
| Vector3 point = start * invPowT; | |
| point += 2 * middle * invT * time; | |
| point += end * powT; | |
| return point; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment