2024-02-16 11:51:05 +00:00
|
|
|
class_name Math
|
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
static func damp(from: Variant, to: Variant, weight: float) -> Variant:
|
2024-02-23 19:13:46 +00:00
|
|
|
return lerp(from, to, 1 - exp(-weight))
|
2024-02-16 11:51:05 +00:00
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
static func dampf(from: float, to: float, weight: float) -> float:
|
2024-02-23 19:13:46 +00:00
|
|
|
return lerpf(from, to, 1 - exp(-weight))
|
2024-02-16 11:51:05 +00:00
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
static func damp_angle(from: float, to: float, weight: float) -> float:
|
2024-02-23 19:13:46 +00:00
|
|
|
return lerp_angle(from, to, 1 - exp(-weight))
|
2024-02-20 22:58:44 +00:00
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
static func damp_spherical(from: Vector3, to: Vector3, weight: float) -> Vector3:
|
2024-02-23 19:13:46 +00:00
|
|
|
return from.slerp(to, 1 - exp(-weight))
|
2024-02-21 19:15:11 +00:00
|
|
|
|
2024-02-27 20:05:55 +00:00
|
|
|
static func damp_vector(from: Vector3, to: Vector3, weight: float) -> Vector3:
|
|
|
|
return from.lerp(to, 1 - exp(-weight))
|
|
|
|
|
2024-02-20 22:58:44 +00:00
|
|
|
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)
|