Author: bugman
Date: Mon Nov 17 17:16:23 2014
New Revision: 26602

URL: http://svn.gna.org/viewcvs/relax?rev=26602&view=rev
Log:
Implemented the lib.geometry.vectors.vector_angle_acos() function.

This is used to calculate the inter-vector angle using the arccos of the dot 
product formula.  The
function has been introduced into the relax library as the calculation is 
repeated throughout relax.


Modified:
    trunk/lib/geometry/vectors.py

Modified: trunk/lib/geometry/vectors.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/geometry/vectors.py?rev=26602&r1=26601&r2=26602&view=diff
==============================================================================
--- trunk/lib/geometry/vectors.py       (original)
+++ trunk/lib/geometry/vectors.py       Mon Nov 17 17:16:23 2014
@@ -103,13 +103,32 @@
     return angle
 
 
+def vector_angle_acos(vector1, vector2):
+    """Calculate the angle between two N-dimensional vectors using the acos 
formula.
+
+    The formula is::
+
+        angle = acos(dot(a / norm(a), b / norm(b))).
+
+
+    @param vector1:     The first vector.
+    @type vector1:      numpy rank-1 array
+    @param vector2:     The second vector.
+    @type vector2:      numpy rank-1 array
+    @return:            The angle between 0 and pi.
+    @rtype:             float
+    """
+
+    # Calculate and return the angle.
+    return acos(dot(vector1 / norm(vector1), vector2 / norm(vector2)))
+
+
 def vector_angle_atan2(vector1, vector2):
     """Calculate the angle between two N-dimensional vectors using the atan2 
formula.
 
     The formula is::
 
         angle = atan2(norm(cross(a, b)), dot(a, b)).
-
 
     This is more numerically stable for angles close to 0 or pi than the 
acos() formula.
 


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to