From 3f3739ccb56fdadab79e17e6a5865381e0821228 Mon Sep 17 00:00:00 2001 From: kobewi Date: Tue, 27 Apr 2021 15:53:04 +0200 Subject: Add Vector2.from_angle() method --- doc/classes/Vector2.xml | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'doc/classes/Vector2.xml') diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index cb5662419e..ab4d0e181a 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -155,6 +155,18 @@ Returns the vector with all components rounded down (towards negative infinity). + + + + + Creates a unit [Vector2] rotated to the given [code]angle[/code] in radians. This is equivalent to doing [code]Vector2(cos(angle), sin(angle))[/code] or [code]Vector2.RIGHT.rotated(angle)[/code]. + [codeblock] + print(Vector2.from_angle(0)) # Prints (1, 0). + print(Vector2(1, 0).angle()) # Prints 0, which is the angle used above. + print(Vector2.from_angle(PI / 2)) # Prints (0, 1). + [/codeblock] + + -- cgit v1.2.3