# Vectors

A vector is a quantity that has a length and a direction. It can be visualized as an arrow. For example, speed and acceleration are vector quantities.

Scalar is a quantity that has not a direction.

A vector v that has its start at the origin and ends at some point P is called the radius vector of this point.

Algebraic projections (x, y, z) of a radius vector on the coordinate axes are called coordinates of vector or point.

You can translate any vector to the origin to get its coordinates. Or you can compute the subtraction of the radius vectors of the end point and start point of the vector.

There are source code in Java related with vectors: VectorFloat and LinearAlgebra classes.

## collinear vectors

Two vectors are collinear, if they lie on the same line or parallel lines.

Two collinear vectors are called co-directed if they have the same direction. They are oppositely directed otherwise.

vectors a and b are collinear if:

`a`_{x}/b_{x}=a_{y}/b_{y}=a_{z}/b_{z}

If *a _{x}/b_{x} > 0*, then

*a*and

*b*are co-directed.

## length of vector

The length of a vector is the square root of the sum of the squares of the coordinates. It is also called as norm of vector.

`∥v∥ = ∥(x,y,z)∥ = sqrt(x*x+y*y+z*z)`

The normalized vector of is a vector in the same direction but with norm 1.

## equal vectors

Two vectors are equal, if they are parallel and of equal length.

Therefore, if we translate a vector it is still considered the same vector. In other words the location does not matter only direction and length.

## zero vector

A vector whose initial and end point are the same is called a zero vector.

The norm of the zero vector is 0. The direction of the zero vector is not defined. Such a vector is collinear to any vector.

## sum of vectors

The the parallelogram method:

- Place both vectors
*a*and*b*at the same initial point. - Complete the parallelogram.
- Diagonal of that parallelogram will be sum of
*a*and*b*. The direction from the initial point to the other end.

Substraction can be presented as *a* + *(-b)*. Change direction of *b* and you will get vector *-b*.

Coordinates of a+b can be computed as:

`c = a + b = ( c`_{x} = a_{x} + b_{x},
c_{y} = a_{y} + b_{y},
c_{z} = a_{z} + b_{z})

Coordinates of a-b can be computed as:

`c = a - b = ( c`_{x} = a_{x} - b_{x},
c_{y} = a_{y} - b_{y},
c_{z} = a_{z} - b_{z})

Properties of addition of vectors:

- Commutative law:
*a + b = b + a* - Associative law:
*a + (b + c) = (a + b) + c* *a + 0 = a*- Existence of the inverse: for every
*a*exists a vector*-a*, so that*a + (-a) = 0*

You can compute the distance between any two points A and B with radius vectors *a* and *b* correspondingly as the norm of the vector *a-b*:

`∥a - b∥ = sqrt( (a`_{x} - b_{x})^{2} + (a_{y} - b_{y})^{2} + (a_{z} - b_{z})^{2})

## scalar multiplication

If *v* is a nonzero vector and *n* is real number, then the product *n*v* is defined to be the vector that has *|n|* times the length of *v* and the same direction as *v*, if *n > 0* and the opposite direction if *n < 0*.

If n = 0 or v = 0, then define *n*v* is zero vector.

Two vectors are proportional if and only if they are collinear. This means one of the vector is a scalar multiple of the other.

Properties of scalar multiplication:

*1*v = v*- Associative law for any number
*n*and*m*:*n*(m*v) = (n*m)*v* - Distributive law for any number
*n*and*m*:*(n+m)*v = k*v + l*v.* - Distributive law for any vectors
*v*and*w*:*n*(v+w) = n*v + n*w.*

## dot product

The dot product is the sum of the products of the corresponding coordinates of the two vectors. It is also known as scalar product.

`a·b = a`_{x}*b_{x} + a_{y}*b_{y} + a_{z}*b_{z}

The dot product has the alternative interpretation as:

`a·b = ∥a∥*∥b∥*cos(α)`

Here *α* is angle between vectors *a* and *b*. It is also
means that two vectors are orthogonal if their dot pruduct is zero.

## cross product

Result of the the cross product *a×b* is a vector *c* that is orthogonal to both *a* and *b*. Length of *c* equal
to the area of the parallelogram defined by *a* and *b*.
Direction is defined by right-hand rule.

```
∥a×b∥ = ∥a∥*∥b∥*sin(α),
where α is angle between a and b
```

Or in coordinate form:

```
a×b =
(|a
```_{y} a_{z}| |a_{z} a_{x}| |a_{x} a_{y}|
|b_{y} b_{z}|, |b_{z} b_{x}|, |b_{x} b_{y}|)
=
(a_{y}*b_{z} − a_{z}*b_{y},
a_{z}*b_{x} − a_{x}*b_{z},
a_{x}*b_{y} − a_{y}*b_{x})

You can read more about determinants of matrices that are used in coordinate form.

Properties of the cross product:

*a×a = 0**a×b = -(b×a)*- Distributive law for addition of vectors:
*a×(b + c) = a×b + a×c* - Distributive law for number multiplication:
*(n*a)×b = a×(n*b)* - Two vectors
*a*and*b*are collinear if*a×b = 0*

## triple product

Triple product of three vectors is defined as

```
|a
```_{x} a_{y} a_{z}|
a·(b×c) = det(a,b,c) = |b_{x} b_{y} b_{z}|
|c_{x} c_{y} c_{z}|

Triple product equal to the value of the signed volume of the parallelepiped defined by three vectors.

Properties

- If vectors a, b and c lie on the same plane, then their triple product is equal to zero.
- If triple product is greater than 0, then vectors a, b and c form a right-handed coordinate system.

## angles between vector and coordinate axes

```
cos(v,Ox) = x/∥v∥ = x/sqrt(x*x+y*y+z*z)
cos(v,Oy) = y/∥v∥ = y/sqrt(x*x+y*y+z*z)
cos(v,Oz) = z/∥v∥ = z/sqrt(x*x+y*y+z*z)
```