point2line
index
 
Name dot ( )
Description Returns the dot product of this vector and another. The dot product value is in fact the cosine of the angle between the two input vectors, multiplied by the lengths of those vectors. So, you can easily calculate the cosine of the angle by either, making sure that your two vectors are both of length 1, or dividing the dot product by the lengths. cos( theta ) = dot( v1, v2 ) / ( magnitude( v1 ) * magnitude( v2 ) ) Values range from 1 to -1. If the two input vectors are pointing in the same direction, then the return value will be 1. If the two input vectors are pointing in opposite directions, then the return value will be -1. If the two input vectors are at right angles, then the return value will be 0. So, in effect, it is telling you how similar the two vectors are.
Syntax
dot(vector1, vector2);
Parameters
vector1   (Vect2)
vector2   (Vect2)
Returns dot product (float)
Usage Web & Application
Related
Examples
import point2line.*;

Vect2 right  = new Vect2( radians( 0 ) );
Vect2 down   = new Vect2( radians( 90 ) );
Vect2 left   = new Vect2( radians( 180 ) );
Vect2 up     = new Vect2( radians( 270 ) );

Vect2 almostRight = new Vect2( radians( 10 ) );

println( Vect2.dot( almostRight, right ) ); // prints "0.9848077"
println( Vect2.dot( almostRight, down ) );  // prints "0.17364813"
println( Vect2.dot( almostRight, left ) );  // prints "-0.9848077"
println( Vect2.dot( almostRight, up ) );    // prints "-0.17364816"