# Dot Product

**Node Description & Purpose: **

The Dot product node takes the Input and Input 2 vectors and outputs the dot product of the two vectors, which is a scalar value. The dot product is the cosine of the angle between the two vectors multiplied by the lengths of the two vectors.

The dot product is useful because it can tell us about the relationship between two vectors. If the dot product equals 0 then the two vectors are at 90º to each other (perpendicular). If the dot product is greater than 0 then two vectors are pointing roughly in the same direction. If the dot product is less than 0 then the two vectors are pointing away from each other.

The dot product is even more useful when the two vectors are unit vectors. In that case the dot product is the cosine of the angle between the two vectors. You can also get the cosine of the angles between non-unit vectors using the following formula:

`cosine = Dot product( vector 1, vector 2 ) ÷ ( Length( vector 1 ) x Length( vector 2 ) )`

The cosine value will range between 1 and -1. If the two vectors are pointing in the same direction the value will be 1. If they're at right angles to each other the value will be 0. If one vector is pointing in exactly the opposite direction to the other vector (i.e. 180º to the other vector) the value will be -1.

To find the actual angle between the vectors in degrees you can do this:

`angle in degrees = Radians to degrees( Arccos( cosine ) )`

**Node Type: ** Function

**Settings: **

This node has just the one setting, which lets you choose a node for Input 2.

A single object or device in the node network which generates or modifies data and may accept input data or create output data or both, depending on its function. Nodes usually have their own settings which control the data they create or how they modify data passing through them. Nodes are connected together in a network to perform work in a network-based user interface. In Terragen 2 nodes are connected together to describe a scene.

A scalar is a single number. 1, 200.45, -45, -0.2 are all examples of scalar values.

A vector is a set of three scalars, normally representing X, Y and Z coordinates. It also commonly represents rotation, where the values are pitch, heading and bank.