diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-20 23:46:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-20 23:46:28 +0200 |
commit | 6746f8b89079d7c51bbf43adae44e0406d24daa8 (patch) | |
tree | 2f23290dd494d02ed14b53455f5f73f38837f56d | |
parent | b7aa4746803554528c6e59650907ebcdf878b8c4 (diff) | |
parent | 1554fce23ccd6702a5653d95c96f9a30fdb9c6e2 (diff) |
Merge pull request #40477 from Calinou/doc-vector-dot
Document `Vector2.dot()` and `Vector3.dot()` more extensively
-rw-r--r-- | doc/classes/Vector2.xml | 5 | ||||
-rw-r--r-- | doc/classes/Vector3.xml | 5 |
2 files changed, 8 insertions, 2 deletions
diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 32895310d1..c97f99cfaa 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -154,7 +154,10 @@ <argument index="0" name="with" type="Vector2"> </argument> <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> </method> <method name="floor"> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index 0c861e5ee2..7ba8cb5eed 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -123,7 +123,10 @@ <argument index="0" name="b" type="Vector3"> </argument> <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> </method> <method name="floor"> |