AMBER Archive (2006)

Subject: Re: AMBER: angle between two vectors

From: M. L. Dodson (mldodson_at_houston.rr.com)
Date: Thu Oct 12 2006 - 12:40:35 CDT


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_at_scripps.edu To unsubscribe, send "unsubscribe amber" to majordomo_at_scripps.edu