Merge pull request #40477 from Calinou/doc-vector-dot

Document `Vector2.dot()` and `Vector3.dot()` more extensively
This commit is contained in:
Rémi Verschelde 2020-07-20 23:46:28 +02:00 committed by GitHub
commit 6746f8b890
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -154,7 +154,10 @@
<argument index="0" name="with" type="Vector2"> <argument index="0" name="with" type="Vector2">
</argument> </argument>
<description> <description>
Returns the dot product with vector [code]b[/code]. Returns the dot product with vector [code]b[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned.
[b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code].
</description> </description>
</method> </method>
<method name="floor"> <method name="floor">

View File

@ -123,7 +123,10 @@
<argument index="0" name="b" type="Vector3"> <argument index="0" name="b" type="Vector3">
</argument> </argument>
<description> <description>
Returns the dot product with [code]b[/code]. Returns the dot product with vector [code]b[/code]. This can be used to compare the angle between two vectors. For example, this can be used to determine whether an enemy is facing the player.
The dot product will be [code]0[/code] for a straight angle (90 degrees), greater than 0 for angles narrower than 90 degrees and lower than 0 for angles wider than 90 degrees.
When using unit (normalized) vectors, the result will always be between [code]-1.0[/code] (180 degree angle) when the vectors are facing opposite directions, and [code]1.0[/code] (0 degree angle) when the vectors are aligned.
[b]Note:[/b] [code]a.dot(b)[/code] is equivalent to [code]b.dot(a)[/code].
</description> </description>
</method> </method>
<method name="floor"> <method name="floor">