Struct Quaternion
- Namespace
- VMagicMirror.Buddy
UnityEngineのQuaternionとほぼ同等のことが出来る四元数のデータです。 回転を表すことを目的として定義されています。
public struct Quaternion : IEquatable<Quaternion>- Implements
- Inherited Members
Constructors
Quaternion(float, float, float, float)
各成分の値を指定してインスタンスを初期化します。
public Quaternion(float x, float y, float z, float w)Parameters
Fields
w
w成分を取得、設定します。
public float wField Value
x
x成分を取得、設定します。
public float xField Value
y
y成分を取得、設定します。
public float yField Value
z
z成分を取得、設定します。
public float zField Value
Properties
eulerAngles
オイラー角として回転を取得、設定します。
public Vector3 eulerAngles { get; set; }Property Value
Remarks
回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。
identity
回転を行わないことを表す値を取得します。
public static Quaternion identity { get; }Property Value
normalized
大きさを正規化した値を取得します。
public Quaternion normalized { get; }Property Value
Methods
Angle(Quaternion, Quaternion)
指定した回転どうしのなす角度を取得します。
public static float Angle(Quaternion a, Quaternion b)Parameters
- aQuaternion
- bQuaternion
Returns
- float
- 指定した回転どうしのなす角度 
AngleAxis(float, Vector3)
度数法で表した回転角および回転軸ベクトルを指定することで、回転を表す値を生成します。
public static Quaternion AngleAxis(float angle, Vector3 axis)Parameters
Returns
- Quaternion
- 指定した角度および軸に基づいた回転 
Dot(Quaternion, Quaternion)
Quaternionをベクトルとして見たときの内積を計算します。
public static float Dot(Quaternion a, Quaternion b)Parameters
- aQuaternion
- bQuaternion
Returns
- float
- 内積の値 
Equals(object)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object other)Parameters
- otherobject
Returns
- bool
- true if - objand this instance are the same type and represent the same value; otherwise, false.
Equals(Quaternion)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(Quaternion other)Parameters
- otherQuaternion
- An object to compare with this object. 
Returns
Euler(float, float, float)
オイラー角を指定して回転を生成します。
public static Quaternion Euler(float x, float y, float z)Parameters
Returns
- Quaternion
- 指定したオイラー角に基づく回転 
Remarks
回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。
Euler(Vector3)
オイラー角を指定して回転を生成します。
public static Quaternion Euler(Vector3 euler)Parameters
- eulerVector3
- xyzの各軸まわりの回転角を度数法で表した値 
Returns
- Quaternion
- 指定したオイラー角に基づく回転 
Remarks
回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。
FromToRotation(Vector3, Vector3)
ある方向から別の方向に向くような回転を取得します。
public static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection)Parameters
Returns
- Quaternion
- fromDirectionから- toDirectionに向くような回転
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()Returns
- int
- A 32-bit signed integer that is the hash code for this instance. 
Inverse(Quaternion)
指定した回転の逆回転を取得します。
public static Quaternion Inverse(Quaternion rotation)Parameters
- rotationQuaternion
- 計算元となる回転 
Returns
- Quaternion
- 逆回転として計算された回転 
LookRotation(Vector3)
ワールド座標上で指定した方向を向くような回転を生成します。
public static Quaternion LookRotation(Vector3 forward)Parameters
- forwardVector3
- 正面を表すワールド座標上の方向 
Returns
- Quaternion
- 指定した方向を向くような回転 
Remarks
この関数では、視点の上方向はupであるものとして計算が行われます。
LookRotation(Vector3, Vector3)
ワールド座標上で指定した方向を向き、かつローカル座標上で上方向が指定した向きになるような回転を生成します。
public static Quaternion LookRotation(Vector3 forward, Vector3 upwards)Parameters
Returns
- Quaternion
- 指定した方向を向くような回転 
Remarks
upwardsは省略可能であり、省略した場合はupが指定されたものとして扱われます。
Set(float, float, float, float)
成分の値を指定してインスタンスを更新します。
public void Set(float newX, float newY, float newZ, float newW)Parameters
Slerp(Quaternion, Quaternion, float)
2つの回転を球面補間した値を取得します。
public static Quaternion Slerp(Quaternion a, Quaternion b, float t)Parameters
- aQuaternion
- tが0のときに適用される回転
- bQuaternion
- tが1のときに適用される回転
- tfloat
- 補間の適用率を表す値。0であれば結果が - aとなり、1であれば結果は- bに一致します。
Returns
- Quaternion
- 補間された回転 
Remarks
tの値は0以上1以下に丸めて適用されます。
SlerpUnclamped(Quaternion, Quaternion, float)
2つの回転を球面補間した値を取得します。
Slerp(Quaternion, Quaternion, float)と異なり、tの値は [0, 1] の範囲に丸められません。
public static Quaternion SlerpUnclamped(Quaternion a, Quaternion b, float t)Parameters
- aQuaternion
- tが0のときに適用される回転
- bQuaternion
- tが1のときに適用される回転
- tfloat
- 補間の適用率を表す値。0であれば結果が - aとなり、1であれば結果は- bに一致します。
Returns
- Quaternion
- 補間された回転 
ToAngleAxis(out float, out Vector3)
回転をdegreeで表した角度と回転軸に分解した値を取得します。
public void ToAngleAxis(out float angle, out Vector3 axis)Parameters
ToString()
Returns the fully qualified type name of this instance.
public override string ToString()Returns
- string
- The fully qualified type name. 
Operators
operator ==(Quaternion, Quaternion)
2つの回転がほぼ等しければ true 、そうでなければ false を返します。
public static bool operator ==(Quaternion lhs, Quaternion rhs)Parameters
- lhsQuaternion
- rhsQuaternion
Returns
operator !=(Quaternion, Quaternion)
2つの回転が異なれば true、ほぼ等しければ false を返します。
public static bool operator !=(Quaternion lhs, Quaternion rhs)Parameters
- lhsQuaternion
- rhsQuaternion
Returns
operator *(Quaternion, Quaternion)
回転を合成します。
public static Quaternion operator *(Quaternion lhs, Quaternion rhs)Parameters
- lhsQuaternion
- rhsQuaternion
Returns
- Quaternion
- 合成した回転 
operator *(Quaternion, Vector3)
回転をベクトルに適用します。
public static Vector3 operator *(Quaternion rotation, Vector3 point)Parameters
- rotationQuaternion
- ベクトルに適用したい回転 
- pointVector3
- 回転させる対象となるベクトル 
Returns
- Vector3
- 回転を適用した状態のベクトル