Hi Monks,

lately I stumbled over my old c++ code
for fast rigid body rotations using
a rotational matrix formalism /1,2/.
Because I needed a snippet to be ready
fast, I rewrote the stuff in plain Perl
without doing a deep investigation into
CPAN first.

After having completed the task, I
started to lookaround there but couldn't
find anything appropriate which does
somehow what I needed.

Simple example - say we have a 3D rigid body
template consisting of 5 coordinates (+ labels):
my @tmpl = ( [0,0,0, 'A'], [1,0,0, 'B'], [2,0,0, 'B'], [3,0,0, 'B'], [4,0,0, 'B'], [5,0,0, 'A'] );
Say we need to construct an ensemble
of copies of rigid bodies by applying random
translations and rotations around ar-
bitary axes on the template,
like (pseudocode):
... my $axis = [ 0, 0, 1 ]; # may be arbitary axis, always normalized my @ensemble; for my $id (0 .. 999) { my $angle = deg2rad(rand(360)); # rotate around arbitary # axis by .. degrees # make rotation matrix my $m = setrotmatrix($angle, $axis); # make new rigid body instance from template my $p = deepcopy_body( \@tmpl ); # apply rotation (matrix x vector) to rigid body rotate_body( $p, $m ); # apply some translation by a displacemnent vector translate_body( $p, [$dx, $dy, $dz)] ); # store the new body coordinates push @ensemble, $p; } ...
The above code should make my intention clear
before I start to work out a module + XS
matrix operations, which modules should I
have considered before?

Regards & thanks

mwa



/1/ - Ha,C. and Radcliffe,C.W. (1978) Kinematics
       and Mechanism Design. Wiley, New York, 45.
/2/ - http://peds.oxfordjournals.org/cgi/reprint/16/10/717

In reply to Doing rigid body rotations in Perl by mwah

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.