sub rotator { use Math::Vector::Real; (*xcord, *ycord, *zcord, *BMatoms, $AxisLineUnitvector, $XlineAxis, $YlineAxis, $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);