# VECTOR OPERATIONS-APPLICATION FOR EDUCATION

Below is an application for practicing addition and subtraction of two vectors, using the vector polygon method as well as the parallelogram method. An option to multiply vectors by a scalar has also been added. It is necessary to create an expression with vectors, and then by clicking on the "Practice" button, start the exercise. To see an introduction to vector operations and writing code in Processing, visit:

**Vectors in Processing**## Addition of vectors

Vectors can be added in two ways: the polygon method and the parallelogram method.

## The Polygon method

Let two vectors "a" and "b" be given (vectors colored light blue in Figure 1). The polygon method consists in connecting one vector to another, so that the beginning of the second coincides with the end of the first (translated vectors a and b, now colored dark blue in the same image). The result is a new vector "c", the beginning of which coincides with the beginning of the first one, and the end with the end of the second one (colored in red in Figure 1). Adding vectors, you can practice with the application "Operations with vectors", located below, on the same page, as well as a video tutorial on how to use it.

In the case of adding two collinear vectors, the resultant is obtained in a similar way, except that it is now in the same line with both vectors, as can be seen in Figure 2.

## Parallelogram method

This method is shown in picture number 3 and consists in first connecting the vectors to each other, so that their beginnings coincide (dark-colored vectors "a" and "b"), and then drawing a parallelogram, so that vectors represent different sides of the parallelogram. The resultant vector is a vector whose origin is common to both vectors being added and extends across the diagonal of the parallelogram, as can be seen in the figure.

## Subtraction of two vectors

The subtraction of two vectors "a-b" is reduced to the addition of the vector and the vector b with the opposite direction, ie. by a vector that is rotated by 180 degrees in the plane of the vector. Vector subtraction is shown in Figure 4. The light blue vectors "a" and "b" are the starting vectors. In the case of the force polygon method, they are added to each other (now colored in a dark color), as in the case of vector addition, and then the vector with a minus sign is rotated by 180 degrees, so that it remains in the same direction, but in the opposite direction, which can be seen in Figure 4. The resultant is now a vector whose beginning is at the beginning of the vector "a", and the end coincides with the end of the vector "-b" (colored red).

When the vectors are collinear, first the vectors "a" and "b" are added to each other, and then the vector "b" is rotated by 180 degrees, to become the vector "-b", i.e. a vector that has the same intensity and direction as the vector "b", but the opposite direction (vectors colored dark blue in Figure 5). The resultant is the vector "c", the beginning of which coincides with the vector "a", and the end with the end of the vector "(-b)" (colored in red in Figure 5)

## Multiplying a vector by a scalar

Suppose that the vector "

Multiplying a vector with a scalar (3 in this example) is done by increasing the intensity of the vector 3 times, while the direction and direction of the vector remain the same (see Figure 5).

**a(20,10)"**is given and the vector**c = 3 * a**needs to be determined.Multiplying a vector with a scalar (3 in this example) is done by increasing the intensity of the vector 3 times, while the direction and direction of the vector remain the same (see Figure 5).

## Video tutorial for using the application: Vector operations

## Use of the application on desktop computers |
## Use of the application on mobile devices |

# Operations with vectors

Animation not working? Please refresh the page

← scroll horizontal →

## Decomposition of vectors into components

A vector can be replaced by its components in any two directions in the plane, but we will consider the decomposition of the vector into the directions of the coordinate axes. The vector "

**a**" can be replaced, for example, by its components ax and ay, which are also vectors and whose direction coincides with the direction of the X and Y axes, respectively. The projection rays passing through the beginning and end of the vector fall perpendicular to these axes, determining the component vectors "**ax**" and "**ay**" for vector a, and "**bx**" and "**by**" for vector**b**, which can be seen in Figure 6. If the vector "

In processing, the vector would be defined via the class

**a**" were defined as e.g.**a(30,20)**then the intensity of the vector "**ax**" would be equal to 30 and the intensity of the vector "**ay**" would be equal to 20.In processing, the vector would be defined via the class

**PVector**, for the java version or via the class**p5.Vector**if it is javascript. In the following, we will define, for example, the vectors "**a**" and "**b**" and then determine and plot the components using processing.Code of this application is shown below:

The "

**draw()**" method is shown at below: Before the

**setup()**method, objects of class**PVector**, positions of vectors "**a**" and "**b**", as well as coordinate axes, vectors "a" and "b", coordinate axes, vector projections were created. These vectors are created in the setup method, and are drawn in the draw method by calling the new "**drawVector()**" method, which draws any vector depending on the sent parameters. The following are sent as parameters: the vector of the position of the beginning of the vector, the vector itself, the color and the thickness of the drawing line. To work with the**PVector**class, read the article:**Vectors in Processing**.After running the code, you will get (see Figure 9):

Continuation of the application in which auxiliary lines will be drawn, markings will be printed, etc. is left to the reader as an exercise.

## Projections of vectors onto coordinate axes

Projecting a vector onto coordinate axes is similar to decomposing a vector into components, with the fact that the projection is a scalar, not a vector quantity, and can have a "

**+**" or "**-**" sign, i.e. it can be positive or negative, and it depends on the direction of the original vector in relation to the X, that is, to the Y axis (see Figure 10).