Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) 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) = @_; $angrad = 9.4; $transl = 0.4; use Math::Trig; #converting deg to rad $angrad = deg2rad($angrad); #coefficient processing $coefl1 = 1-cos($angrad); $coefl2 = sin($angrad); #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>


In reply to Rotation around an axis clockwise and anti-clockwise algorithm question? by fraizerangus

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (8)
    As of 2014-09-18 08:31 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (109 votes), past polls