docs.unity3d.com
    目次を表示する/隠す

    Rotate About Axis ノード

    説明

    入力ベクトル In を、Rotation の値の分だけ、軸 Axis を中心に回転させます。回転角度の単位は Unit パラメーターで選択できます。

    ポート

    Name Direction タイプ バインディング 説明
    In 入力 Vector 3 なし 入力値
    Axis 入力 Vector 3 なし 回転の軸
    Rotation 入力 Vector 1 なし 適用する回転の量
    Out 出力 Vector 3 なし 出力値

    制御

    Name タイプ オプション 説明
    Unit ドロップダウン Radians, Degrees 入力 Rotation の単位を切り替えます。

    生成されるコードの例

    以下のサンプルコードは、Unit モード毎に、このノードの出力の一例を示したものです。

    Radians

    void Unity_RotateAboutAxis_Radians_float(float3 In, float3 Axis, float Rotation, out float3 Out)
    {
        float s = sin(Rotation);
        float c = cos(Rotation);
        float one_minus_c = 1.0 - c;
    
        Axis = normalize(Axis);
        float3x3 rot_mat = 
        {   one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
            one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
            one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
        };
        Out = mul(rot_mat,  In);
    }
    

    Degrees

    void Unity_RotateAboutAxis_Degrees_float(float3 In, float3 Axis, float Rotation, out float3 Out)
    {
        Rotation = radians(Rotation);
        float s = sin(Rotation);
        float c = cos(Rotation);
        float one_minus_c = 1.0 - c;
    
        Axis = normalize(Axis);
        float3x3 rot_mat = 
        {   one_minus_c * Axis.x * Axis.x + c, one_minus_c * Axis.x * Axis.y - Axis.z * s, one_minus_c * Axis.z * Axis.x + Axis.y * s,
            one_minus_c * Axis.x * Axis.y + Axis.z * s, one_minus_c * Axis.y * Axis.y + c, one_minus_c * Axis.y * Axis.z - Axis.x * s,
            one_minus_c * Axis.z * Axis.x - Axis.y * s, one_minus_c * Axis.y * Axis.z + Axis.x * s, one_minus_c * Axis.z * Axis.z + c
        };
        Out = mul(rot_mat,  In);
    }
    
    トップに戻る
    Copyright © 2023 Unity Technologies — 商標と利用規約
    • 法律関連
    • プライバシーポリシー
    • クッキー
    • 私の個人情報を販売または共有しない
    • Your Privacy Choices (Cookie Settings)