Re: AMBER: angle between two vectors

From: M. L. Dodson <mldodson.houston.rr.com>
Date: Thu, 12 Oct 2006 12:40:35 -0500

On Thursday 12 October 2006 11:51, Lwin, ThuZar wrote:
> Hello,
>
>
>
> Do you have any suggestion on how to do the following using
> amber ptraj?
>
> Vector 1: Assign a vector between atom A and B.
>
> Vector 2: Assign another vector between atom C and D.
>
> Then calculate angle between vector 1 and vector 2.
>
>
>
> Thank you,
>
> Thu Zar

Don't know the ptraj incantation to do it, but here is the
algorithm in nab:

// Angle between two vectors
float angle_arc(point av, point tv)
{
  float d;
  point rv;
  // The acos of the dot product gives us the rotation angle magnitude,
  d = acos(av . tv);
  // and the cross product gives us the sign
  rv = av ^ tv;
  if (rv.z > 0.0) return(d);
  else return(-d);
};

In nab a point variable contains the Cartesian coordinates of a
point. In your case, if A, B, C, and D are the coordinates of the
corresponding points:

anglebetween = angle_arc(B - A, D - C);

-- 
M. L. Dodson
Email:	mldodson-at-houston-dot-rr-dot-com
Phone:	eight_three_two-56_three-386_one
-----------------------------------------------------------------------
The AMBER Mail Reflector
To post, send mail to amber.scripps.edu
To unsubscribe, send "unsubscribe amber" to majordomo.scripps.edu
Received on Thu Oct 12 2006 - 20:36:15 PDT
Custom Search