2020-01-28 00:31:10 +01:00
|
|
|
# A desired linear and angular amount of acceleration requested by the steering
|
|
|
|
# system.
|
2020-04-03 02:31:59 +02:00
|
|
|
# @category - Base types
|
2023-01-13 13:09:18 +01:00
|
|
|
extends Reference
|
2020-02-11 18:33:25 +01:00
|
|
|
class_name GSAITargetAcceleration
|
2019-12-16 17:22:03 +01:00
|
|
|
|
2020-01-28 00:31:10 +01:00
|
|
|
# Linear acceleration
|
2023-01-13 13:09:18 +01:00
|
|
|
var linear : Vector3 = Vector3.ZERO
|
2020-01-28 00:31:10 +01:00
|
|
|
# Angular acceleration
|
2023-01-13 13:09:18 +01:00
|
|
|
var angular : float = 0.0
|
2019-12-16 17:22:03 +01:00
|
|
|
|
2020-01-28 00:31:10 +01:00
|
|
|
# Sets the linear and angular components to 0.
|
2019-12-19 20:04:08 +01:00
|
|
|
func set_zero() -> void:
|
2019-12-16 17:22:03 +01:00
|
|
|
linear.x = 0.0
|
|
|
|
linear.y = 0.0
|
|
|
|
linear.z = 0.0
|
|
|
|
angular = 0.0
|
2019-12-21 03:32:21 +01:00
|
|
|
|
2020-01-27 18:57:51 +01:00
|
|
|
# Adds `accel`'s components, multiplied by `scalar`, to this one.
|
2020-02-11 18:33:25 +01:00
|
|
|
func add_scaled_accel(accel: GSAITargetAcceleration, scalar: float) -> void:
|
2019-12-21 03:32:21 +01:00
|
|
|
linear += accel.linear * scalar
|
|
|
|
angular += accel.angular * scalar
|
|
|
|
|
2020-01-28 00:31:10 +01:00
|
|
|
# Returns the squared magnitude of the linear and angular components.
|
2019-12-23 17:38:27 +01:00
|
|
|
func get_magnitude_squared() -> float:
|
2019-12-21 03:32:21 +01:00
|
|
|
return linear.length_squared() + angular * angular
|
|
|
|
|
2020-01-28 00:31:10 +01:00
|
|
|
# Returns the magnitude of the linear and angular components.
|
2019-12-21 03:32:21 +01:00
|
|
|
func get_magnitude() -> float:
|
2019-12-23 17:38:27 +01:00
|
|
|
return sqrt(get_magnitude_squared())
|