Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 15:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found