How can I get the sum of these components for the dot product?
3 views (last 30 days)
Show older comments
I'm working on a class file dealing with dual quaternions and am trying to create a function for the dot product. However, I am unable to sum the components for the real and dual components. So far I have the following:
function obj = dotprod(a,b)
obj = Dualquaternion;
obj.realpart.scal = a.realpart.scal*b.realpart.scal;
obj.dualpart.scal = a.dualpart.scal*b.dualpart.scal;
obj.realpart.vect = a.realpart.vect.*b.realpart.vect;
obj.dualpart.vect = a.dualpart.vect.*b.dualpart.vect;
obj.realpart = obj.realpart.scal + obj.realpart.vect;
obj.dualpart = obj.dualpart.scal + obj.dualpart.vect;
obj = DualNumber(obj.realpart,obj.dualpart);
So for example, when I have two dual quaternions such as
a = (1 + 1i + 1j + 1k) + epsilon*(2 + 2i + 2j + 2k)
b = (2 + 2i + 2j + 2k) + epsilon*(1 + 1i + 1j + 1k)
the output should be a dual number like
ans = 8 + epsilon*(8)
However, I'm getting something like (4 4 4) + epsilon * ( 4 4 4 )
Edit: I am also using the Kinematics Toolbox by Daniel Klawitter
1 Comment
Adam
on 9 May 2017
Aside from the question of Quaternians which I don't know enough about, don't use 'obj' twice in a function. Theoretically it works because Matlab will happily reassign the type of a variable mid-function and even in a single expression, but it isn't a good idea. Just call the first object something else if it isn't the one being returned.
Answers (0)
See Also
Categories
Find more on Coordinate Transformations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!