Dot operator
The dot operator has two different meanings:
- For 2D and 3D vector this operator corresponds to the dot product as you would expect.
- For a quaternion this operator corresponds to the quaternion multiplication.
2D and 3D dot product
vecmath> a=[7,-9]
vecmath> b=[2,3]
vecmath> dab=a.b
vecmath> print dab
1
2
3
4
2
3
4
The result of this operator is off course a scalar:
dab = [-13]
1
A 3D example:
vecmath> a=[7,-9,1]
vecmath> b=[2,3,-3]
vecmath> dab=a.b
vecmath> print dab
1
2
3
4
2
3
4
The result of this operator is again a scalar:
dab = [-16]
1
Quaternion multiplication
The dot operator can be used to perform the quaternion complex multiplication and off course also to calculate a rotation with the sandwich formula. The result of this operator on quaternions is a new quaternion:
vecmath> q1=[1,(-9,1,2)]
vecmath> q2=[3,(2,-3,4)]
vecmath> q3=q1.q2
vecmath> print q3
1
2
3
4
2
3
4
The resulting quaternion is :
q3 = [16 ,( -15 , 40 , 35 )]
1