Skip to content

PVector tutorial: fix typos and broken links (#464) #635

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
9 changes: 6 additions & 3 deletions content/tutorials/text/pvector/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ In the above example, we have a very simple world -- a blank canvas with a circu

- LOCATION: x and y
- SPEED: xspeed and yspeed

In a more advanced sketch, we could imagine this ball and world having many more properties:
- ACCELERATION: xacceleration and yacceleration
- TARGET LOCATION: xtarget and ytarget
Expand Down Expand Up @@ -118,7 +119,7 @@ Here are some vectors and possible translations:

</FixedImage>

You've probably done this before when programming motion. For every frame of animation (i.e. single cycle through Processing's (http://processing.org/reference/draw_.html)draw()] loop), you instruct each object on the screen to move a certain number of pixels horizontally and a certain number of pixels (vertically).
You've probably done this before when programming motion. For every frame of animation (i.e. single cycle through Processing's [draw()](http://processing.org/reference/draw_.html) loop), you instruct each object on the screen to move a certain number of pixels horizontally and a certain number of pixels (vertically).

For a Processing programmer, we can now understand a vector as the instructions for moving a shape from point A to point B, an object's &ldquo;pixel velocity&rdquo; so to speak.

Expand Down Expand Up @@ -192,7 +193,7 @@ In an ideal world, we would just be able to rewrite the above to be:
location = location + velocity;
```

However, in Processing, the addition operator '+' is reserved for primitive values (integers, floats, etc.) only. Processing doesn't know how to add two **PVector**](http://processing.org/reference/PVector.html) objects together any more than it knows how to add two PFont objects or PImage objects. Fortunately for us, the [**PVector**](http://processing.org/reference/PVector.html) class is implemented with functions for common mathematical operations.
However, in Processing, the addition operator '+' is reserved for primitive values (integers, floats, etc.) only. Processing doesn't know how to add two [**PVector**](http://processing.org/reference/PVector.html) objects together any more than it knows how to add two PFont objects or PImage objects. Fortunately for us, the [**PVector**](http://processing.org/reference/PVector.html) class is implemented with functions for common mathematical operations.

## Vectors: Addition

Expand Down Expand Up @@ -421,7 +422,7 @@ The fancy terminology and symbols aside, this is really quite a simple concept.

</HighlightBlock>

Moving onto multiplication, we have to think a little bit differently. When we talk about multiplying a vector what we usually mean is **_scaling_** a vector. Maybe we want a vector to be twice its size or one-third its size, etc. In this case, we are saying &ldquo;Multiply a vector by 2&rdquo; or &ldquo;Multiply a vector by 1/3&rquo;. Note we are multiplying a vector by a scalar, a single number, not another vector.
Moving onto multiplication, we have to think a little bit differently. When we talk about multiplying a vector what we usually mean is **_scaling_** a vector. Maybe we want a vector to be twice its size or one-third its size, etc. In this case, we are saying &ldquo;Multiply a vector by 2&rdquo; or &ldquo;Multiply a vector by 1/3&rdquo;. Note we are multiplying a vector by a scalar, a single number, not another vector.

To scale a vector by a single number, we multiply each component (x and y) by that number.

Expand Down Expand Up @@ -522,7 +523,9 @@ u.div(2);
As with addition, basic algebraic rules of multiplication and division apply to vectors.

The associative rule: (n\*m)**\*v** = n\*(m**\*v**)

The distributive rule, 2 scalars, 1 vector: (n + m)**\*v** = n**\*v** + m**\*v**

The distributive rule, 2 vectors, 1 scalar : (**u** +**v**)\*n = n**\*u** + n**\*v**

</HighlightBlock>
Expand Down