XP is just a number PerlMonks

### Comment on

 Need Help??
Hello Monks

I've written a program which rotates atoms (with a set rotation and translation) around an axis for a Bioinformatics program I'm working on, it works going in one direction, does anyone know of a simple tweak I could do make it rotate in the opposite (anti-clockwise direction) please, which wouldn't involve me re-writing the whole program again?

```
sub rotator {

use Math::Vector::Real;

(*xcord, *ycord, *zcord, *BMatoms, \$AxisLineUnitvector, \$XlineAxis, \$Y
+lineAxis, \$ZlineAxis) = @_;

\$transl = 0.4;

use Math::Trig;

#converting deg to rad

#coefficient processing

#Breakdown axis line vector into constituent X,Y & Z co-ordinates
(\$LUVx, \$LUVy, \$LUVz) = &VectorBreakdown(\$AxisLineUnitvector);

#for loop to process all atoms
for (my \$i = 0; \$i < @BMatoms; \$i++) {

#distances of co-ordinates to axis line
\$Xco[\$i] = \$xcord[\$i] - \$XlineAxis;
\$Yco[\$i] = \$ycord[\$i] - \$YlineAxis;
\$Zco[\$i] = \$zcord[\$i] - \$ZlineAxis;

#convert diatance co-ordinates into a vector
\$Vector[\$i] = V(\$Xco[\$i], \$Yco[\$i], \$Zco[\$i]);

#dot product
\$scal[\$i] = \$LineUnitvector * \$Vector[\$i];

#scalar product
\$f[\$i] = (\$scal[\$i] * \$AxisLineUnitvector) - \$Vector[\$i];

#dot product
\$f[\$i] = \$coefl1 * \$f[\$i];

#cross product
\$s[\$i] = \$AxisLineUnitvector x \$Vector[\$i];

#dot product
\$s[\$i] = \$coefl2 * \$s[\$i];

#vector broken down into constituent parts
(\$fx[\$i], \$fy[\$i], \$fz[\$i]) = &VectorBreakdown(\$f[\$i]);
(\$sx[\$i], \$sy[\$i], \$sz[\$i]) = &VectorBreakdown(\$s[\$i]);

#new co-ordinates
\$xo[\$i] = \$xcord[\$i] + \$fx[\$i] + \$sx[\$i] + (\$transl * \$LUVx);
\$yo[\$i] = \$ycord[\$i] + \$fy[\$i] + \$sy[\$i] + (\$transl * \$LUVy);
\$zo[\$i] = \$zcord[\$i] + \$fz[\$i] + \$sz[\$i] + (\$transl * \$LUVz);

#rounding up
\$xo[\$i] = sprintf("%.3f",\$xo[\$i]);
\$yo[\$i] = sprintf("%.3f",\$yo[\$i]);
\$zo[\$i] = sprintf("%.3f",\$zo[\$i]);

}

return(\@xo, \@yo, \@zo);

Many Thanks in advance! <\p>

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, 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, 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?
• See Writeup Formatting Tips and other pages linked from there for more info.

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2018-05-20 18:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
World peace can best be achieved by:

Results (150 votes). Check out past polls.

Notices?