mwah has asked for the wisdom of the Perl Monks concerning the following question:
Say we need to construct an ensemblemy @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'] );
The above code should make my intention clear... 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; } ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Doing rigid body rotations in Perl
by moklevat (Priest) on Oct 03, 2007 at 20:03 UTC | |
|
Re: Doing rigid body rotations in Perl
by zentara (Cardinal) on Oct 04, 2007 at 13:49 UTC |