Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Rotate around Axis#

Math / Rotate around Axis

  • Can Read

  • Cannot Write

Description#

Turns a vector a certain amount of degrees around an axis of rotation

Parameters#

Name Description
Vector The vector that is rotated
Axis The direction the vector turns around
Degrees How much the vector turns around the axis

Code#

using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Title("Rotate around Axis")]
    [Category("Math/Rotate around Axis")]

    [Description("Turns a vector a certain amount of degrees around an axis of rotation")]
    [Image(typeof(IconRotation), ColorTheme.Type.Yellow)]

    [Parameter("Vector", "The vector that is rotated")]
    [Parameter("Axis", "The direction the vector turns around")]
    [Parameter("Degrees", "How much the vector turns around the axis")]

    [Keywords("Vector", "Turn", "Spin", "Angle", "Degrees", "Pivot", "Orbit")]

    [Serializable]
    public class TypeVector3MathRotateAroundAxis : TypeVector3
    {
        [SerializeField] private GetVector3 m_Vector = new GetVector3();
        [SerializeField] private GetVector3 m_Axis = new GetVector3(Vector3.up);
        [SerializeField] private GetNumber m_Degrees = new GetNumber(90f);

        public override Vector3 GetPreview(GameObject source) => Rotate(
            this.m_Vector.GetPreview(source),
            this.m_Axis.GetPreview(source),
            this.m_Degrees.GetPreview(source)
        );

        public override Vector3 Get(Args args) => Rotate(
            this.m_Vector.Get(args),
            this.m_Axis.Get(args),
            this.m_Degrees.Get(args)
        );

        private static Vector3 Rotate(Vector3 vector, Vector3 axis, double degrees)
        {
            if (axis.sqrMagnitude <= Mathf.Epsilon) return vector;
            return Quaternion.AngleAxis((float) degrees, axis.normalized) * vector;
        }

        public override string ToString()
        {
            return $"Rotate {this.m_Vector} {this.m_Degrees} around {this.m_Axis}";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.