docs.unity3d.com
    Show / Hide Table of Contents

    Rotate Node

    Description

    Rotates value of input UV around a reference point defined by input Center by the amount of input Rotation. The unit for rotation angle can be selected by the parameter Unit.

    Ports

    Name Direction Type Binding Description
    UV Input Vector 2 UV Input UV value
    Center Input Vector 2 None Center point to rotate around
    Rotation Input Float None Amount of rotation to apply
    Out Output Vector 2 None Output UV value

    Controls

    Name Type Options Description
    Unit Dropdown Radians, Degrees Switches the unit for input Rotation

    Generated Code Example

    The following example code represents one possible outcome of this node per Unit mode.

    Radians

    void Unity_Rotate_Radians_float(float2 UV, float2 Center, float Rotation, out float2 Out)
    {
        UV -= Center;
        float s = sin(Rotation);
        float c = cos(Rotation);
        float2x2 rMatrix = float2x2(c, -s, s, c);
        rMatrix *= 0.5;
        rMatrix += 0.5;
        rMatrix = rMatrix * 2 - 1;
        UV.xy = mul(UV.xy, rMatrix);
        UV += Center;
        Out = UV;
    }
    

    Degrees

    void Unity_Rotate_Degrees_float(float2 UV, float2 Center, float Rotation, out float2 Out)
    {
        Rotation = Rotation * (3.1415926f/180.0f);
        UV -= Center;
        float s = sin(Rotation);
        float c = cos(Rotation);
        float2x2 rMatrix = float2x2(c, -s, s, c);
        rMatrix *= 0.5;
        rMatrix += 0.5;
        rMatrix = rMatrix * 2 - 1;
        UV.xy = mul(UV.xy, rMatrix);
        UV += Center;
        Out = UV;
    }
    
    In This Article
    • Description
    • Ports
    • Controls
    • Generated Code Example
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023