bom/client/math/Math.gd

15 lines
619 B
GDScript3
Raw Normal View History

2024-02-16 12:51:05 +01:00
class_name Math
static func damp(from: Variant, to: Variant, weight: float, smoothing: float = 0.75):
return lerp(from, to, 1 - exp(-smoothing * weight))
static func dampf(from: float, to: float, weight: float, smoothing: float = 0.75):
return lerpf(from, to, 1 - exp(-smoothing * weight))
static func damp_angle(from: float, to: float, weight: float, smoothing: float = 0.75):
2024-02-20 23:58:44 +01:00
return lerp_angle(from, to, 1 - exp(-smoothing * weight))
static func from_to_rotation(from: Vector3, to: Vector3) -> Quaternion:
var axis := from.cross(to).normalized()
var angle := from.angle_to(to)
return Quaternion(axis, angle)