Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify the difference between Vector2/3's reflect() and bounce() #68392

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion doc/classes/Vector2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
<return type="Vector2" />
<param index="0" name="n" type="Vector2" />
<description>
Returns the vector "bounced off" from a plane defined by the given normal.
Returns the vector "bounced off" from a plane defined by the given normal [param n].
[b]Note:[/b] [method bounce] performs [i]physical[/i] reflection, as opposed to [method reflect] which performs [i]mathematical[/i] reflection. Double-check which method you actually need to use, as other engines may use these terms differently.
</description>
</method>
<method name="ceil" qualifiers="const">
Expand Down Expand Up @@ -311,6 +312,7 @@
<param index="0" name="n" type="Vector2" />
<description>
Returns the vector reflected (i.e. mirrored, or symmetric) over a line defined by the given direction vector [param n].
[b]Note:[/b] [method reflect] performs [i]mathematical[/i] reflection, as opposed to [method bounce] which performs [i]physical[/i] reflection. Double-check which method you actually need to use, as other engines may use these terms differently.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

performs [i]mathematical[/i] reflection

I'm not sure that this is properly called "mathematical" reflection. From what I can see, "n" is always the normal vector (i.e. pointing perpendicular from the surface). While in this case "n" is not the normal, but the plane itself.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little more insight, the wikipedia page for "reflection (mathematics)" gives a definition for reflection the same as what we use for reflection, but calls the parameter "line" instead of "normal". (https://en.wikipedia.org/wiki/Reflection_(mathematics))

Bounce on the other hand, is a mathematical reflection over a normal. It is also equivalent to -vec.reflect()

Instead of calling them "mathematical reflection" and "physical reflection" I would highlight that you are reflecting over a normal vector perpendicular to the plane, or a vector describing the plane itself. So you are either "bouncing off a surface with normal n" or you are "reflecting across the surface n"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So you are either "bouncing off a surface with normal n"

Isn't that what bounce() does?

</description>
</method>
<method name="rotated" qualifiers="const">
Expand Down
6 changes: 4 additions & 2 deletions doc/classes/Vector3.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
Returns the vector "bounced off" from a plane defined by the given normal.
Returns the vector "bounced off" from a plane defined by the given normal [param n].
[b]Note:[/b] [method bounce] performs [i]physical[/i] reflection, as opposed to [method reflect] which performs [i]mathematical[/i] reflection.
</description>
</method>
<method name="ceil" qualifiers="const">
Expand Down Expand Up @@ -294,7 +295,8 @@
<return type="Vector3" />
<param index="0" name="n" type="Vector3" />
<description>
Returns this vector reflected from a plane defined by the given normal.
Returns the vector reflected (i.e. mirrored, or symmetric) over a plane defined by the given direction vector [param n].
[b]Note:[/b] [method reflect] performs [i]mathematical[/i] reflection, as opposed to [method bounce] which performs [i]physical[/i] reflection. Double-check which method you actually need to use, as other engines may use these terms differently.
</description>
</method>
<method name="rotated" qualifiers="const">
Expand Down