SIVector3.Dot

Description

Returns the dot product of this vector and vector v. A dot product is defined as :

X . Y = |X| |Y| cos( theta )

Where theta is the angle between your vectors and |X| is the length of the vector X.

C# Syntax

Double SIVector3.Dot( SIVector3 in_pVector );

Scripting Syntax

oFloat = SIVector3.Dot( v );

Return Value

Floating point value (dot product of this vector and vector v).

Parameters

Parameter Type Description
v SIVector3 Operand vector

Examples

1. JScript Example

x = XSIMath.CreateVector3();
y = XSIMath.CreateVector3();
// Example 1: Perpendicular vectors have 0 dot product
x.Set( 1,0,0 ) ;
y.Set( 0,1,0 ) ;
// Output is 0
Application.LogMessage( x.Dot( y ) ) ;
// Example 2: Commutative nature of dot product
x.Set( 2,0,0 ) ;
y.Set( 1,1,0 ) ;
// Output is 2 for both
Application.LogMessage( x.Dot( y ) ) ;
Application.LogMessage( y.Dot( x ) ) ;
// Example 3: When angle is zero the value
// is equal to the lengths multipled
x.Set( 2,0,0 ) ;
y.Set( 3,0,0 ) ;
//Output is 6 for both
Application.LogMessage( x.Dot( y ) ) ;
Application.LogMessage( x.length() * y.length() ) ;

2. VBScript Example

dim v1, v2
' Create 3D vectors.
set v1 = XSIMath.CreateVector3
set v2 = XSIMath.CreateVector3
v1.Set 1.0, 0.0, 0.0
v2.Set 1.0, 1.0, 0.0
Application.LogMessage v1.Dot( v2 )

See Also

SIVector3.Angle SIMatrix3 SIMatrix4 SIRotation SITransformation SIQuaternion