Get length of rotation

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

I know how to get the length of a vector 2 but there is something similar for rotation.

velocity =  Vector2()
velocity.length()

Not sure I follow. What do you consider the length of a rotation? Maybe the length of the arc segment between rotationA and rotationB at some (yet-to-be-specified) distance?

jgodfrey | 2020-12-02 20:52

If you mean how to get the rotation from a Node2D, just use its rotation property as follows:

$My_Node.rotation

magicalogic | 2020-12-03 05:01

:bust_in_silhouette: Reply From: Thomas Karcher

Both jgodfrey and _magicalogic_ are right: You can’t get a “length of rotation” without specifying a radius. You can either get the angle with $My_Node.rotation (like _magicalogic_ said), or get the length of the arc segment at a specific radius, like jgodfrey said. For the latter, there’s no inbuilt function (as far as I’m aware), but you can easily create one yourself:

func get_length_of_rotation (angle: float, radius: float) -> float:
	var circumference : float = 2.0 * PI * radius
	var fraction : float = angle / (2.0 * PI)
	return circumference / fraction