2014年7月9日水曜日

Unity3D の回転とクオータニオンのリファレンスリンク

Unity3D (4.5.1) の回転と姿勢とクオータニオン関連の関数とか変数を、目に付いた範囲でまとめてみる。どう使うかの解説を書こうと思ったが、、、ま、次の記事で「伝わらない」記事を書こう。

視点としては、次の3視点で関連のある関数・変数をまとめた。
  • Phyxエンジンを用いた姿勢制御(Rigidbody)
  • Transformを直接変更するスタイルの姿勢制御(回転制御)
  • Vector3, Quaternionによって、状態変数の変更を行う計算関連
並びはクラスごととした。用途ごとにまとめようかとも思ったが、まずはもっとも見通しのよいスタイルにした。

回転と姿勢制御関連のリファレンス

リンク先は、UnityのScriptAPI Reference である。日本語にリンクしている。関数と変数の表記法は、C#の方式にしている。私がC#使うからである。UnityScriptとBooについては、リンク先で確認されたい。

注意点として、クラスに含まれる関数、変数を「すべて」紹介しているわけではない。省略された中にも回転制御に関連のある関数・変数はある。かもしれない。今のところ意図的に省いたのはRigidbody.AddForceだけ。他にあったらこっそり使わずに教えてくださいおねがいします

今回調査したクラス一覧

  • Rigidbodyクラス
  • Transformクラス
  • Vector3クラス
  • Quaternionクラス

Rigidbodyクラス

変数

  • AddTorque
    • void AddTorque(Vector3 torque, ForceMode mode = ForceMode.Force);
    • void AddTorque(float x, float y, float z, ForceMode mode = ForceMode.Force);
  • AddRelativeTorque
    • void AddRelativeTorque(Vector3 torque, ForceMode mode = ForceMode.Force);
    • void AddRelativeTorque(float x, float y, float z, ForceMode mode = ForceMode.Force);
  • MoveRotation
    • void MoveRotation(Quaternion rot);

Transformクラス

変数

  • LookAt
    • void LookAt(Transform target, Vector3 worldUp = Vector3.up);
    • void LookAt(Vector3 worldPosition, Vector3 worldUp = Vector3.up);
  • Rotate
    • void Rotate(Vector3 eulerAngles, Space relativeTo = Space.Self);
    • void Rotate(float xAngle, float yAngle, float zAngle, Space relativeTo = Space.Self);
    • void Rotate(Vector3 axis, float angle, Space relativeTo = Space.Self);
  • RotateAround
    • void RotateAround(Vector3 point, Vector3 axis, float angle);

Vector3クラス

Static 関数

  • Angle
    • static float Angle(Vector3 from, Vector3 to);
  • Lerp
    • static Vector3 Lerp(Vector3 from, Vector3 to, float t);
  • MoveTowards
    • static Vector3 MoveTowards(Vector3 current, Vector3 target, float maxDistanceDelta);
  • RotateTowards
    • static Vector3 RotateTowards(Vector3 current, Vector3 target, float maxRadiansDelta, float maxMagnitudeDelta);
  • Slerp
    • static Vector3 Slerp(Vector3 from, Vector3 to, float t);
  • SmoothDamp
    • static Vector3 SmoothDamp(Vector3 current, Vector3 target, Vector3 currentVelocity, float smoothTime, float maxSpeed = Mathf.Infinity, float deltaTime = Time.deltaTime);

Quaternionクラス

変数

コンストラクター

関数

  • SetFromToRotation
    • void SetFromToRotation(Vector3 fromDirection, Vector3 toDirection);
  • SetLookRotation
    • void SetLookRotation(Vector3 view, Vector3 up = Vector3.up);
  • ToAngleAxis
    • void ToAngleAxis(float angle, Vector3 axis);

Static関数

  • Angle
    • static float Angle(Quaternion a, Quaternion b);
  • AngleAxis
    • static Quaternion AngleAxis(float angle, Vector3 axis);
  • Euler
    • static Quaternion Euler(float x, float y, float z);
    • static Quaternion Euler(Vector3 euler);
  • FromToRotation
    • static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection);
  • Lerp
    • static Quaternion Lerp(Quaternion from, Quaternion to, float t);
  • LookRotation
    • static Quaternion LookRotation(Vector3 forward, Vector3 upwards = Vector3.up);
  • RotateTowards
    • static Quaternion RotateTowards(Quaternion from, Quaternion to, float maxDegreesDelta);
  • Slerp
    • static Quaternion Slerp(Quaternion from, Quaternion to, float t);

演算子(Operators)

  • * 演算子
    • static Quaternion operator *(Quaternion lhs, Quaternion rhs);

以上である!


0 件のコメント:

コメントを投稿