Hi Everyone I know this is a slightly more mathematical based question but I thought it was worth just asking here just in case, I'm trying to calculate the shortest distance of every atom in a PDB file to an axis in the protein, I'm using the following algorithm but it does'nt appear to work? is there something I'm doing wrong or has anyone come across this problem and got code for it?
$A = x(point) - x(line point 1); $B = y(point) - y(line point 1); $C = x(line point 2) - x(line point 1); $D = y(line point 2) - y(line point 1); $dot = (($A * $C) + ($B * $D)); $len_sq = ((C * C) + (D * D)); $param = (dot / len_sq); if($param < 0) { $xx = x(line point 1); $yy = y(line point 2); } else if($param > 1) { $xx = $x(line point 2); $yy = $y(line point 2); } else { $xx = x(line point 1) + $param * $C; $yy = y(line point 1) + $param * $D; } $dist = sqrt((($x(point) - $xx) * ($x(point) - $xx)) + (($y(point) - $ +yy) * ($y(point) - $yy)) + (($z(point) - $zz) * ($z(point) - $zz)));

In reply to perl module or code for calculating the shortest distance between a line and a point (vector linear algebra) 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!
  • 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, details, 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, summary, 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:
    & &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.