How can I get the sum of these components for the dot product?
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commento
Adam
il 9 Mag 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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su Coordinate Transformations in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!