how to interpolate between 2 angles in 3d?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Thakee Nathees

what’s the best way to interpolate between two angles in 3d?

:bust_in_silhouette: Reply From: BraindeadBZH

Usually the best to interpolate values manually is to use the lerp function: @GDScript — Godot Engine (stable) documentation in English

:bust_in_silhouette: Reply From: Dlean Jeans

Use this function:

func lerp_angle(from, to, weight):
    return from + short_angle_dist(from, to) * weight

func short_angle_dist(from, to):
    var max_angle = PI * 2
    var difference = fmod(to - from, max_angle)
    return fmod(2 * difference, max_angle) - difference