mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #105488 from Calinou/doc-vector2-from-angle-not-normalized
Document `Vector2.from_angle()` not always returning a normalized vector
This commit is contained in:
commit
00be4c3bb4
1 changed files with 2 additions and 1 deletions
|
@ -211,12 +211,13 @@
|
|||
<return type="Vector2" />
|
||||
<param index="0" name="angle" type="float" />
|
||||
<description>
|
||||
Creates a unit [Vector2] rotated to the given [param angle] in radians. This is equivalent to doing [code]Vector2(cos(angle), sin(angle))[/code] or [code]Vector2.RIGHT.rotated(angle)[/code].
|
||||
Creates a [Vector2] rotated to the given [param angle] 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, 0.0)
|
||||
print(Vector2(1, 0).angle()) # Prints 0.0, which is the angle used above.
|
||||
print(Vector2.from_angle(PI / 2)) # Prints (0.0, 1.0)
|
||||
[/codeblock]
|
||||
[b]Note:[/b] The length of the returned [Vector2] is [i]approximately[/i] [code]1.0[/code], but is is not guaranteed to be exactly [code]1.0[/code] due to floating-point precision issues. Call [method normalized] on the returned [Vector2] if you require a unit vector.
|
||||
</description>
|
||||
</method>
|
||||
<method name="is_equal_approx" qualifiers="const">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue