<br><br><div class="gmail_quote">On Tue, Jun 30, 2009 at 12:26 PM, Nils Wagner <span dir="ltr"><<a href="mailto:nwagner@iam.uni-stuttgart.de">nwagner@iam.uni-stuttgart.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tue, 30 Jun 2009 11:10:39 -0600<br>
<div><div></div><div class="h5">  Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
> On Tue, Jun 30, 2009 at 10:56 AM, Charles R Harris <<br>
> <a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
><br>
>><br>
>><br>
>> On Tue, Jun 30, 2009 at 10:40 AM, Nils Wagner <<br>
>> <a href="mailto:nwagner@iam.uni-stuttgart.de">nwagner@iam.uni-stuttgart.de</a>> wrote:<br>
>><br>
>>> On Tue, 30 Jun 2009 10:27:05 -0600<br>
>>>  Charles R Harris <<a href="mailto:charlesr.harris@gmail.com">charlesr.harris@gmail.com</a>> wrote:<br>
>>> > On Tue, Jun 30, 2009 at 5:11 AM, Nils Wagner<br>
>>> > <<a href="mailto:nwagner@iam.uni-stuttgart.de">nwagner@iam.uni-stuttgart.de</a>>wrote:<br>
>>> ><br>
>>> >> On Tue, 30 Jun 2009 11:22:34 +0200<br>
>>> >>  "Nils Wagner" <<a href="mailto:nwagner@iam.uni-stuttgart.de">nwagner@iam.uni-stuttgart.de</a>> wrote:<br>
>>> >><br>
>>> >>>  Hi all,<br>
>>> >>><br>
>>> >>> How can I build the following product with numpy<br>
>>> >>><br>
>>> >>> q_i = \varepsilon_{ijk} q_{kj}<br>
>>> >>><br>
>>> >>> where  \varepsilon_{ijk} denotes the permutation<br>
>>>symbol.<br>
>>> >>><br>
>>> >>> Nils<br>
>>> >>><br>
>>> >>  Sorry for replying to myself.<br>
>>> >> The permutation symbol is also known as the<br>
>>>Levi-Civita<br>
>>> >>symbol.<br>
>>> >> I found an explicit expression at<br>
>>> >> <a href="http://en.wikipedia.org/wiki/Levi-Civita_symbol" target="_blank">http://en.wikipedia.org/wiki/Levi-Civita_symbol</a><br>
>>> >><br>
>>> >> How do I build the product of the Levi-Civita symbol<br>
>>> >>\varepsilon_{ijk} and<br>
>>> >> the two dimensional array<br>
>>> >> q_{kj}, i,j,k = 1,2,3 ?<br>
>>> >><br>
>>> ><br>
>>> > Write it out explicitly. It essentially<br>
>>>antisymmetrizes<br>
>>> >q and the three off<br>
>>> > diagonal elements can then be treated as a vector.<br>
>>> >Depending on how q is<br>
>>> > formed and the resulting vector is used there may be<br>
>>> >other things you can do<br>
>>> > when you use it in a more general expression. If this<br>
>>>is<br>
>>> >part of a general<br>
>>> > calculation there might be other ways of expressing<br>
>>>it.<br>
>>> ><br>
>>> > Chuck<br>
>>><br>
>>> Hi Chuck,<br>
>>><br>
>>> Thank you for your response.<br>
>>> The problem at hand is described in a paper by Angeles<br>
>>> namely equation (17c) in<br>
>>> "Automatic computation of the screw parameters of<br>
>>> rigid-body motions.<br>
>>> Part I: Finitely-separated positions"<br>
>>> Journal of Dynamic systems, Measurement and Control,<br>
>>>Vol.<br>
>>> 108 (1986) pp. 32-38<br>
>>><br>
>><br>
>> You can solve this problem using quaternions also, in<br>
>>which case it reduces<br>
>> to an eigenvalue problem. You will note that such things<br>
>>as PCA are used in<br>
>> the papers that reference the cited work so you can't<br>
>>really get around that<br>
>> bit of inefficiency.<br>
>><br>
><br>
> Here's a reference to the quaternion approach:<br>
> <a href="http://people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf" target="_blank">http://people.csail.mit.edu/bkph/papers/Absolute_Orientation.pdf</a>.<br>
>You can<br>
> get the translation part from the motion of the<br>
>centroid.<br>
><br>
> If you are into abstractions you will note that the<br>
>problem reduces to<br>
> minimising a quadratic form in the quaternion<br>
>components. The rest is just<br>
> algebra ;)<br>
><br>
> Chuck<br>
<br>
</div></div>It turns out that the product is simply an invariant of a<br>
3 \times 3 matrix.<br>
<br>
from numpy import array, zeros, identity<br>
from numpy.linalg import norm<br>
<br>
<br>
def vect(A):<br>
     """ linear invariant of a 3 x 3 matrix """<br>
     tmp = zeros(3,float)<br>
     tmp[0] = 0.5*(A[2,1]-A[1,2])<br>
     tmp[1] = 0.5*(A[0,2]-A[2,0])<br>
     tmp[2] = 0.5*(A[1,0]-A[0,1])<br>
<br>
     return tmp<br>
</blockquote><div><br>Yep, that's writing it out explicitly.<br><br>Chuck <br></div><br></div><br>