[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-dev] [IMP-commits] r1414 - trunk/modules/algebra/include



Given we already have rotation from_fixed_xyz which is a form of euler angles, this function should probably have a more descriptive name describing which Euler angles it uses.


On Feb 2, 2009, at 10:10 PM, Notification of IMP commits wrote:

Author: 
Date: 2009-02-02 22:10:39 -0800 (Mon, 02 Feb 2009)
New Revision: 1414

Modified:
  trunk/modules/algebra/include/Rotation3D.h
Log:
add rotation_from_euler

Modified: trunk/modules/algebra/include/Rotation3D.h
===================================================================
--- trunk/modules/algebra/include/Rotation3D.h 2009-02-03 03:11:05 UTC (rev 1413) +++ trunk/modules/algebra/include/Rotation3D.h 2009-02-03 06:10:39 UTC (rev 1414)
@@ -114,6 +114,24 @@
  return Rotation3D(a,b,c,d);
}

+//! Initialize a rotation from euler angles
+/**
+   \note http://en.wikipedia.org/wiki/
+         Conversion_between_quaternions_and_Euler_angles
+    \relates Rotation3D
+*/
+inline Rotation3D rotation_from_euler(Float phi, Float theta, Float psi)
+{
+  Float a,b,c,d;
+  Float c1,c2,c3,s1,s2,s3;
+  c2=cos(theta/2);c1=cos(phi/2);c3=cos(psi/2);
+  s2=sin(theta/2);s1=sin(phi/2);s3=sin(psi/2);
+  a = c1*c2*c3+s1*s2*s3;
+  b = s1*c2*c3-c1*s2*s3;
+  c = c1*s2*c3+s1*c2*s3;
+  d = c1*c2*s3-s1*s2*c3;
+  return Rotation3D(a,b,c,d);
+}
//! Generate a Rotation3D object from a rotation matrix
/**
   \throw ValueException if the rotation is not a rotation matrix.

_______________________________________________
IMP-commits mailing list

https://salilab.org/mailman/listinfo/imp-commits