Dot Product

From Terragen Documentation from Planetside Software
Revision as of 18:37, 1 June 2011 by JavaJones (talk | contribs)
Jump to: navigation, search

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

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

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.