---
tags:
    - "Lerp"
    - "Slerp"
    - "Linear"
    - "Smooth"
    - "Damp"
    - "Angle"
    - "Degrees"
    - "Step"
---

# Interpolate Angle

[Math](../index.md) / [Algebra](index.md) / **Interpolate Angle**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Interpolates a value between A and B given a ratio number wrapped around 360

## Code

```cs
using System;
using UnityEngine;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]
    
    [Title("Interpolate Angle")]
    [Category("Math/Algebra/Interpolate Angle")]
    
    [Description("Interpolates a value between A and B given a ratio number wrapped around 360")]
    [Image(typeof(IconInterpolate), ColorTheme.Type.Yellow, typeof(BadgeAlpha))]
    
    [Keywords("Lerp", "Slerp", "Linear", "Smooth", "Damp", "Angle", "Degrees", "Step")]
    
    [Serializable]
    public class TypeNumberMathInterpolateAngle : TypeNumber
    {
        [SerializeField] private GetNumber m_AngleA = new GetNumber();
        [SerializeField] private GetNumber m_AngleB = new GetNumber();
        
        [SerializeField] private GetNumber m_Ratio = new GetNumber();
        [SerializeField] private EaseMode m_Easing = EaseMode.Linear;

        public override double GetPreview(GameObject source)
        {
            float ratio = Ease.Get(this.m_Easing, (float) this.m_Ratio.GetPreview(source));
            return Interpolate(this.m_AngleA.GetPreview(source), this.m_AngleB.GetPreview(source), ratio);
        }

        public override double Get(Args args)
        {
            double a = this.m_AngleA.Get(args);
            double b = this.m_AngleB.Get(args);
            
            double ratio = Ease.Get(this.m_Easing, (float) this.m_Ratio.Get(args));
            return Interpolate(a, b, ratio);
        }

        private static double Interpolate(double a, double b, double ratio)
        {
            return Mathf.LerpAngle((float) a, (float) b, (float) ratio);
        }

        public override string ToString()
        {
            return $"Interpolate {this.m_AngleA} to {this.m_AngleB} by {this.m_Ratio}";
        }
        
        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
```

