Edited vector_math.rst (added clarifications) (#595)

* Adding clarifications in vector_math.rst
This commit is contained in:
amirea
2017-11-22 01:25:45 +02:00
committed by Andrew Conrad
parent f0726f923a
commit e8919d905b

View File

@@ -60,7 +60,7 @@ Vector Operations
You can use either method (x and y coordinates or angle and magnitude) to
refer to a vector, but for convenience programmers typically use the
coordinate notation. For example, in Godot the origin is the top-left
corner of the screen, so to place a 2D node 400 pixels to the right and
corner of the screen, so to place a 2D node named ``Node2D`` 400 pixels to the right and
300 pixels down, use the following code:
::
@@ -123,7 +123,7 @@ Let's look at two common uses for vector addition and subtraction.
- Movement
A vector can represent **any** quantity with a magnitude and direction. In
A vector can represent **any** quantity with a magnitude and direction. Typical examples are: position, velocity, acceleration, and force. In
this image, the spaceship at step 1 has a position vector of ``(1,3)`` and
a velocity vector of ``(2,1)``. The velocity vector represents how far the
ship moves each step. We can find the position for step 2 by adding
@@ -161,7 +161,7 @@ by its magnitude:
::
var a = Vector2(2, 4)
var m = sqrt(a.x*a.x + a.y*a.y)
var m = sqrt(a.x*a.x + a.y*a.y) # get magnitude "m" using the Pythagorean theorem
a.x /= m
a.y /= m
@@ -198,7 +198,7 @@ to handle this. Here is a GDScript example of the diagram above using a
::
var collision = move_and_collide(velocity * delta)
var collision = move_and_collide(velocity * delta) # object "collision" contains information about the collision
if collision:
var reflect = collision.remainder.bounce(collision.normal)
velocity = velocity.bounce(collision.normal)
@@ -243,7 +243,7 @@ Facing
We can use this fact to detect whether an object is facing toward another
object. In the diagram below, the player ``P`` is trying to avoid the
zombies ``A`` and ``B``. Can the zombies see the player?
zombies ``A`` and ``B``. Assuming a zombie's field of view is **180°**, can they see the player?
.. image:: img/vector_facing2.png