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)));