Table of Contents

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

x float
y float
z float
w float

Fields

w

w成分を取得、設定します。

public float w

Field Value

float

x

x成分を取得、設定します。

public float x

Field Value

float

y

y成分を取得、設定します。

public float y

Field Value

float

z

z成分を取得、設定します。

public float z

Field Value

float

Properties

eulerAngles

オイラー角として回転を取得、設定します。

public Vector3 eulerAngles { get; set; }

Property Value

Vector3

Remarks

回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。

identity

回転を行わないことを表す値を取得します。

public static Quaternion identity { get; }

Property Value

Quaternion

normalized

大きさを正規化した値を取得します。

public Quaternion normalized { get; }

Property Value

Quaternion

Methods

Angle(Quaternion, Quaternion)

指定した回転どうしのなす角度を取得します。

public static float Angle(Quaternion a, Quaternion b)

Parameters

a Quaternion
b Quaternion

Returns

float

指定した回転どうしのなす角度

AngleAxis(float, Vector3)

度数法で表した回転角および回転軸ベクトルを指定することで、回転を表す値を生成します。

public static Quaternion AngleAxis(float angle, Vector3 axis)

Parameters

angle float

度数法で表した回転角

axis Vector3

回転軸ベクトル

Returns

Quaternion

指定した角度および軸に基づいた回転

Dot(Quaternion, Quaternion)

Quaternionをベクトルとして見たときの内積を計算します。

public static float Dot(Quaternion a, Quaternion b)

Parameters

a Quaternion
b Quaternion

Returns

float

内積の値

Equals(object)

Indicates whether this instance and a specified object are equal.

public override bool Equals(object other)

Parameters

other object

Returns

bool

true if obj and 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

other Quaternion

An object to compare with this object.

Returns

bool

true if the current object is equal to the other parameter; otherwise, false.

Euler(float, float, float)

オイラー角を指定して回転を生成します。

public static Quaternion Euler(float x, float y, float z)

Parameters

x float

x軸まわりの回転角を度数法で表した値

y float

y軸まわりの回転角を度数法で表した値

z float

z軸まわりの回転角を度数法で表した値

Returns

Quaternion

指定したオイラー角に基づく回転

Remarks

回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。

Euler(Vector3)

オイラー角を指定して回転を生成します。

public static Quaternion Euler(Vector3 euler)

Parameters

euler Vector3

xyzの各軸まわりの回転角を度数法で表した値

Returns

Quaternion

指定したオイラー角に基づく回転

Remarks

回転の適用順はUnityEngine.Quaternionに準じており、YXZの順に適用されます。

FromToRotation(Vector3, Vector3)

ある方向から別の方向に向くような回転を取得します。

public static Quaternion FromToRotation(Vector3 fromDirection, Vector3 toDirection)

Parameters

fromDirection Vector3
toDirection Vector3

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

rotation Quaternion

計算元となる回転

Returns

Quaternion

逆回転として計算された回転

LookRotation(Vector3)

ワールド座標上で指定した方向を向くような回転を生成します。

public static Quaternion LookRotation(Vector3 forward)

Parameters

forward Vector3

正面を表すワールド座標上の方向

Returns

Quaternion

指定した方向を向くような回転

Remarks

この関数では、視点の上方向はupであるものとして計算が行われます。

LookRotation(Vector3, Vector3)

ワールド座標上で指定した方向を向き、かつローカル座標上で上方向が指定した向きになるような回転を生成します。

public static Quaternion LookRotation(Vector3 forward, Vector3 upwards)

Parameters

forward Vector3

正面を表すワールド座標上の方向

upwards Vector3

カメラの上方向を表すようなワールド座標上の方向

Returns

Quaternion

指定した方向を向くような回転

Remarks

upwardsは省略可能であり、省略した場合はupが指定されたものとして扱われます。

Set(float, float, float, float)

成分の値を指定してインスタンスを更新します。

public void Set(float newX, float newY, float newZ, float newW)

Parameters

newX float
newY float
newZ float
newW float

Slerp(Quaternion, Quaternion, float)

2つの回転を球面補間した値を取得します。

public static Quaternion Slerp(Quaternion a, Quaternion b, float t)

Parameters

a Quaternion

tが0のときに適用される回転

b Quaternion

tが1のときに適用される回転

t float

補間の適用率を表す値。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

a Quaternion

tが0のときに適用される回転

b Quaternion

tが1のときに適用される回転

t float

補間の適用率を表す値。0であれば結果がaとなり、1であれば結果はbに一致します。

Returns

Quaternion

補間された回転

ToAngleAxis(out float, out Vector3)

回転をdegreeで表した角度と回転軸に分解した値を取得します。

public void ToAngleAxis(out float angle, out Vector3 axis)

Parameters

angle float

度数法で表した回転角度

axis Vector3

回転軸の単位ベクトル

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

lhs Quaternion
rhs Quaternion

Returns

bool

operator !=(Quaternion, Quaternion)

2つの回転が異なれば true、ほぼ等しければ false を返します。

public static bool operator !=(Quaternion lhs, Quaternion rhs)

Parameters

lhs Quaternion
rhs Quaternion

Returns

bool

operator *(Quaternion, Quaternion)

回転を合成します。

public static Quaternion operator *(Quaternion lhs, Quaternion rhs)

Parameters

lhs Quaternion
rhs Quaternion

Returns

Quaternion

合成した回転

operator *(Quaternion, Vector3)

回転をベクトルに適用します。

public static Vector3 operator *(Quaternion rotation, Vector3 point)

Parameters

rotation Quaternion

ベクトルに適用したい回転

point Vector3

回転させる対象となるベクトル

Returns

Vector3

回転を適用した状態のベクトル