Re: [IMP-dev] [IMP-commits] r854 - trunk/modules/misc/include
I don't like having two equivalent constructors from thevsame data or using a vector to hold angles.
What I had meant with my suggestion is initialization from an axis and an amount of rotation about that axis as that is a somewhat less problematic basis than Euler angles (and one I use :-)
On Nov 12, 2008, at 2:31 PM, Notification of IMP commits <imp-commits@salilab.org > wrote:
> Author: kerenl@SALILAB.ORG > Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) > New Revision: 854 > > Modified: > trunk/modules/misc/include/Rotation3D.h > Log: > 1. Change protected to private > 2. Add constructors from Vector3D and an angle > 3. update documentation > > Modified: trunk/modules/misc/include/Rotation3D.h > =================================================================== > --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 > UTC (rev 853) > +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 > UTC (rev 854) > @@ -19,26 +19,28 @@ > > class IMPMISCEXPORT Rotation3D { > public: > - //! Initialize a rotation in x-y-z order from three angles > + Rotation3D(){ > + } > + //! Initialize a rotation in x-y-z order from three Euler angles > /** \param[in] xr Rotation around the X axis > \param[in] yr Rotation around the Y axis > \param[in] zr Rotation around the Z axis > */ > Rotation3D(Float xr, Float yr, Float zr) { > - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > - Float m00 = cz*cy; > - Float m11 = -sy*sx*sz + cx*cz; > - Float m22 = cy*cx; > - quat_[0] = sqrt(1+m00+m11+m22)/2.0; > - quat_[1] = sqrt(1+m00-m11-m22)/2.0; > - quat_[2] = sqrt(1-m00+m11-m22)/2.0; > - quat_[3] = sqrt(1-m00-m11+m22)/2.0; > - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > + init_angles(xr,yr,zr); > } > - > + //! Initialize a rotation in x-y-z order from three identical > Euler angles > + /** \param[in] e_angle Rotation around first the X axis, Y axis > and Z axis > + */ > + Rotation3D(Float e_angle){ > + init_angles(e_angle, e_angle, e_angle); > + } > + //! Initialize a rotation in x-y-z order from three Euler angles > + /** \param[in] v A vector that holds three Euler angles (x-y-z > order) > + */ > + Rotation3D(const Vector3D &v){ > + init_angles(v[0],v[1],v[2]); > + } > Matrix3D get_matrix() const { > const Float a = quat_[0]; > const Float b = quat_[1]; > @@ -76,7 +78,22 @@ > return atan2(matrix21(), matrix11()); > } > > -protected: > +private: > + void init_angles(Float xr, Float yr, Float zr) { > + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > + Float m00 = cz*cy; > + Float m11 = -sy*sx*sz + cx*cz; > + Float m22 = cy*cx; > + quat_[0] = sqrt(1+m00+m11+m22)/2.0; > + quat_[1] = sqrt(1+m00-m11-m22)/2.0; > + quat_[2] = sqrt(1-m00+m11-m22)/2.0; > + quat_[3] = sqrt(1-m00-m11+m22)/2.0; > + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > + } > + > Float matrix11() const { > return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - > sqr(quat_[3]); > } > > _______________________________________________ > IMP-commits mailing list > IMP-commits@salilab.org > https://salilab.org/mailman/listinfo/imp-commits
Daniel - the angles are not Euler angles but just three angles around X/Y/Z axis. Would you like the option to rotate around another axis, ,something like: (1,1,0),45 - meaning rotating around the diagonal of the XY plane in 45 degrees? On Nov 12, 2008, at 5:43 PM, Daniel Russel wrote:
> I don't like having two equivalent constructors from thevsame data or > using a vector to hold angles. > > What I had meant with my suggestion is initialization from an axis and > an amount of rotation about that axis as that is a somewhat less > problematic basis than Euler angles (and one I use :-) > > > > On Nov 12, 2008, at 2:31 PM, Notification of IMP commits <imp-commits@salilab.org >> wrote: > >> Author: kerenl@SALILAB.ORG >> Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) >> New Revision: 854 >> >> Modified: >> trunk/modules/misc/include/Rotation3D.h >> Log: >> 1. Change protected to private >> 2. Add constructors from Vector3D and an angle >> 3. update documentation >> >> Modified: trunk/modules/misc/include/Rotation3D.h >> =================================================================== >> --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 >> UTC (rev 853) >> +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 >> UTC (rev 854) >> @@ -19,26 +19,28 @@ >> >> class IMPMISCEXPORT Rotation3D { >> public: >> - //! Initialize a rotation in x-y-z order from three angles >> + Rotation3D(){ >> + } >> + //! Initialize a rotation in x-y-z order from three Euler angles >> /** \param[in] xr Rotation around the X axis >> \param[in] yr Rotation around the Y axis >> \param[in] zr Rotation around the Z axis >> */ >> Rotation3D(Float xr, Float yr, Float zr) { >> - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >> - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >> - Float m00 = cz*cy; >> - Float m11 = -sy*sx*sz + cx*cz; >> - Float m22 = cy*cx; >> - quat_[0] = sqrt(1+m00+m11+m22)/2.0; >> - quat_[1] = sqrt(1+m00-m11-m22)/2.0; >> - quat_[2] = sqrt(1-m00+m11-m22)/2.0; >> - quat_[3] = sqrt(1-m00-m11+m22)/2.0; >> - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >> - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >> - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >> + init_angles(xr,yr,zr); >> } >> - >> + //! Initialize a rotation in x-y-z order from three identical >> Euler angles >> + /** \param[in] e_angle Rotation around first the X axis, Y axis >> and Z axis >> + */ >> + Rotation3D(Float e_angle){ >> + init_angles(e_angle, e_angle, e_angle); >> + } >> + //! Initialize a rotation in x-y-z order from three Euler angles >> + /** \param[in] v A vector that holds three Euler angles (x-y-z >> order) >> + */ >> + Rotation3D(const Vector3D &v){ >> + init_angles(v[0],v[1],v[2]); >> + } >> Matrix3D get_matrix() const { >> const Float a = quat_[0]; >> const Float b = quat_[1]; >> @@ -76,7 +78,22 @@ >> return atan2(matrix21(), matrix11()); >> } >> >> -protected: >> +private: >> + void init_angles(Float xr, Float yr, Float zr) { >> + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >> + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >> + Float m00 = cz*cy; >> + Float m11 = -sy*sx*sz + cx*cz; >> + Float m22 = cy*cx; >> + quat_[0] = sqrt(1+m00+m11+m22)/2.0; >> + quat_[1] = sqrt(1+m00-m11-m22)/2.0; >> + quat_[2] = sqrt(1-m00+m11-m22)/2.0; >> + quat_[3] = sqrt(1-m00-m11+m22)/2.0; >> + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >> + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >> + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >> + } >> + >> Float matrix11() const { >> return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - >> sqr(quat_[3]); >> } >> >> _______________________________________________ >> IMP-commits mailing list >> IMP-commits@salilab.org >> https://salilab.org/mailman/listinfo/imp-commits > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev
On Nov 12, 2008, at 10:33 PM, Keren Lasker wrote:
> Daniel - the angles are not Euler angles but just three angles around > X/Y/Z axis. It is not entirely clear to me what the constructor does, but I suspect it is one of the things that gets called Euler rotations (but I haven't looked at Euler angles in a while). I think it needs to be made clearer whether the rotation is about the rotated or unrotated versions of the specified axis.
Why are we providing initialization from such a representation anyway? Is there some use for which they are better than quaternions?
> > Would you like the option to rotate around another axis, ,something > like: > (1,1,0),45 - meaning rotating around the diagonal of the XY plane in > 45 degrees? Yes, although radians are probably preferable. Basically a non- normalized quaternion.
> > On Nov 12, 2008, at 5:43 PM, Daniel Russel wrote: > >> I don't like having two equivalent constructors from thevsame data or >> using a vector to hold angles. >> >> What I had meant with my suggestion is initialization from an axis >> and >> an amount of rotation about that axis as that is a somewhat less >> problematic basis than Euler angles (and one I use :-) >> >> >> >> On Nov 12, 2008, at 2:31 PM, Notification of IMP commits <imp-commits@salilab.org >>> wrote: >> >>> Author: kerenl@SALILAB.ORG >>> Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) >>> New Revision: 854 >>> >>> Modified: >>> trunk/modules/misc/include/Rotation3D.h >>> Log: >>> 1. Change protected to private >>> 2. Add constructors from Vector3D and an angle >>> 3. update documentation >>> >>> Modified: trunk/modules/misc/include/Rotation3D.h >>> =================================================================== >>> --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 >>> UTC (rev 853) >>> +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 >>> UTC (rev 854) >>> @@ -19,26 +19,28 @@ >>> >>> class IMPMISCEXPORT Rotation3D { >>> public: >>> - //! Initialize a rotation in x-y-z order from three angles >>> + Rotation3D(){ >>> + } >>> + //! Initialize a rotation in x-y-z order from three Euler angles >>> /** \param[in] xr Rotation around the X axis >>> \param[in] yr Rotation around the Y axis >>> \param[in] zr Rotation around the Z axis >>> */ >>> Rotation3D(Float xr, Float yr, Float zr) { >>> - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >>> - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >>> - Float m00 = cz*cy; >>> - Float m11 = -sy*sx*sz + cx*cz; >>> - Float m22 = cy*cx; >>> - quat_[0] = sqrt(1+m00+m11+m22)/2.0; >>> - quat_[1] = sqrt(1+m00-m11-m22)/2.0; >>> - quat_[2] = sqrt(1-m00+m11-m22)/2.0; >>> - quat_[3] = sqrt(1-m00-m11+m22)/2.0; >>> - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >>> - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >>> - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >>> + init_angles(xr,yr,zr); >>> } >>> - >>> + //! Initialize a rotation in x-y-z order from three identical >>> Euler angles >>> + /** \param[in] e_angle Rotation around first the X axis, Y axis >>> and Z axis >>> + */ >>> + Rotation3D(Float e_angle){ >>> + init_angles(e_angle, e_angle, e_angle); >>> + } >>> + //! Initialize a rotation in x-y-z order from three Euler angles >>> + /** \param[in] v A vector that holds three Euler angles (x-y-z >>> order) >>> + */ >>> + Rotation3D(const Vector3D &v){ >>> + init_angles(v[0],v[1],v[2]); >>> + } >>> Matrix3D get_matrix() const { >>> const Float a = quat_[0]; >>> const Float b = quat_[1]; >>> @@ -76,7 +78,22 @@ >>> return atan2(matrix21(), matrix11()); >>> } >>> >>> -protected: >>> +private: >>> + void init_angles(Float xr, Float yr, Float zr) { >>> + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >>> + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >>> + Float m00 = cz*cy; >>> + Float m11 = -sy*sx*sz + cx*cz; >>> + Float m22 = cy*cx; >>> + quat_[0] = sqrt(1+m00+m11+m22)/2.0; >>> + quat_[1] = sqrt(1+m00-m11-m22)/2.0; >>> + quat_[2] = sqrt(1-m00+m11-m22)/2.0; >>> + quat_[3] = sqrt(1-m00-m11+m22)/2.0; >>> + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >>> + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >>> + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >>> + } >>> + >>> Float matrix11() const { >>> return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - >>> sqr(quat_[3]); >>> } >>> >>> _______________________________________________ >>> IMP-commits mailing list >>> IMP-commits@salilab.org >>> https://salilab.org/mailman/listinfo/imp-commits >> _______________________________________________ >> IMP-dev mailing list >> IMP-dev@salilab.org >> https://salilab.org/mailman/listinfo/imp-dev > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev
On Nov 12, 2008, at 6:55 PM, Daniel Russel wrote:
> > On Nov 12, 2008, at 10:33 PM, Keren Lasker wrote: > >> Daniel - the angles are not Euler angles but just three angles around >> X/Y/Z axis. > It is not entirely clear to me what the constructor does, but I > suspect it is one of the things that gets called Euler rotations (but > I haven't looked at Euler angles in a while). I think it needs to be > made clearer whether the rotation is about the rotated or unrotated > versions of the specified axis. > > Why are we providing initialization from such a representation anyway? > Is there some use for which they are better than quaternions? > look at the latest version of Rotation3D class - I added some documentation on quaternions >> >> Would you like the option to rotate around another axis, ,something >> like: >> (1,1,0),45 - meaning rotating around the diagonal of the XY plane in >> 45 degrees? > Yes, although radians are probably preferable. Basically a non- > normalized quaternion. yes we use radians - this is just for readability :) > > > >> >> On Nov 12, 2008, at 5:43 PM, Daniel Russel wrote: >> >>> I don't like having two equivalent constructors from thevsame data >>> or >>> using a vector to hold angles. >>> >>> What I had meant with my suggestion is initialization from an axis >>> and >>> an amount of rotation about that axis as that is a somewhat less >>> problematic basis than Euler angles (and one I use :-) >>> >>> >>> >>> On Nov 12, 2008, at 2:31 PM, Notification of IMP commits <imp-commits@salilab.org >>>> wrote: >>> >>>> Author: kerenl@SALILAB.ORG >>>> Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) >>>> New Revision: 854 >>>> >>>> Modified: >>>> trunk/modules/misc/include/Rotation3D.h >>>> Log: >>>> 1. Change protected to private >>>> 2. Add constructors from Vector3D and an angle >>>> 3. update documentation >>>> >>>> Modified: trunk/modules/misc/include/Rotation3D.h >>>> =================================================================== >>>> --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 >>>> UTC (rev 853) >>>> +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 >>>> UTC (rev 854) >>>> @@ -19,26 +19,28 @@ >>>> >>>> class IMPMISCEXPORT Rotation3D { >>>> public: >>>> - //! Initialize a rotation in x-y-z order from three angles >>>> + Rotation3D(){ >>>> + } >>>> + //! Initialize a rotation in x-y-z order from three Euler angles >>>> /** \param[in] xr Rotation around the X axis >>>> \param[in] yr Rotation around the Y axis >>>> \param[in] zr Rotation around the Z axis >>>> */ >>>> Rotation3D(Float xr, Float yr, Float zr) { >>>> - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >>>> - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >>>> - Float m00 = cz*cy; >>>> - Float m11 = -sy*sx*sz + cx*cz; >>>> - Float m22 = cy*cx; >>>> - quat_[0] = sqrt(1+m00+m11+m22)/2.0; >>>> - quat_[1] = sqrt(1+m00-m11-m22)/2.0; >>>> - quat_[2] = sqrt(1-m00+m11-m22)/2.0; >>>> - quat_[3] = sqrt(1-m00-m11+m22)/2.0; >>>> - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >>>> - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >>>> - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >>>> + init_angles(xr,yr,zr); >>>> } >>>> - >>>> + //! Initialize a rotation in x-y-z order from three identical >>>> Euler angles >>>> + /** \param[in] e_angle Rotation around first the X axis, Y axis >>>> and Z axis >>>> + */ >>>> + Rotation3D(Float e_angle){ >>>> + init_angles(e_angle, e_angle, e_angle); >>>> + } >>>> + //! Initialize a rotation in x-y-z order from three Euler angles >>>> + /** \param[in] v A vector that holds three Euler angles (x-y-z >>>> order) >>>> + */ >>>> + Rotation3D(const Vector3D &v){ >>>> + init_angles(v[0],v[1],v[2]); >>>> + } >>>> Matrix3D get_matrix() const { >>>> const Float a = quat_[0]; >>>> const Float b = quat_[1]; >>>> @@ -76,7 +78,22 @@ >>>> return atan2(matrix21(), matrix11()); >>>> } >>>> >>>> -protected: >>>> +private: >>>> + void init_angles(Float xr, Float yr, Float zr) { >>>> + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); >>>> + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); >>>> + Float m00 = cz*cy; >>>> + Float m11 = -sy*sx*sz + cx*cz; >>>> + Float m22 = cy*cx; >>>> + quat_[0] = sqrt(1+m00+m11+m22)/2.0; >>>> + quat_[1] = sqrt(1+m00-m11-m22)/2.0; >>>> + quat_[2] = sqrt(1-m00+m11-m22)/2.0; >>>> + quat_[3] = sqrt(1-m00-m11+m22)/2.0; >>>> + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; >>>> + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; >>>> + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; >>>> + } >>>> + >>>> Float matrix11() const { >>>> return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - >>>> sqr(quat_[3]); >>>> } >>>> >>>> _______________________________________________ >>>> IMP-commits mailing list >>>> IMP-commits@salilab.org >>>> https://salilab.org/mailman/listinfo/imp-commits >>> _______________________________________________ >>> IMP-dev mailing list >>> IMP-dev@salilab.org >>> https://salilab.org/mailman/listinfo/imp-dev >> >> _______________________________________________ >> IMP-dev mailing list >> IMP-dev@salilab.org >> https://salilab.org/mailman/listinfo/imp-dev > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev
>> >> > look at the latest version of Rotation3D class - I added some > documentation on quaternions Sure, but why do we support construction from the (possibly) Euler angles at all?
I think these are Euler angles. http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index... Daniel, I agree that conceptually it is wrong to store them in Vector3D, but it is very convenient in practice.
On Wed, Nov 12, 2008 at 10:33 PM, Keren Lasker kerenl@salilab.org wrote:
> Daniel - the angles are not Euler angles but just three angles around > X/Y/Z axis. > Would you like the option to rotate around another axis, ,something > like: > (1,1,0),45 - meaning rotating around the diagonal of the XY plane in > 45 degrees? > On Nov 12, 2008, at 5:43 PM, Daniel Russel wrote: > > > I don't like having two equivalent constructors from thevsame data or > > using a vector to hold angles. > > > > What I had meant with my suggestion is initialization from an axis and > > an amount of rotation about that axis as that is a somewhat less > > problematic basis than Euler angles (and one I use :-) > > > > > > > > On Nov 12, 2008, at 2:31 PM, Notification of IMP commits < > imp-commits@salilab.org > >> wrote: > > > >> Author: kerenl@SALILAB.ORG > >> Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) > >> New Revision: 854 > >> > >> Modified: > >> trunk/modules/misc/include/Rotation3D.h > >> Log: > >> 1. Change protected to private > >> 2. Add constructors from Vector3D and an angle > >> 3. update documentation > >> > >> Modified: trunk/modules/misc/include/Rotation3D.h > >> =================================================================== > >> --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 > >> UTC (rev 853) > >> +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 > >> UTC (rev 854) > >> @@ -19,26 +19,28 @@ > >> > >> class IMPMISCEXPORT Rotation3D { > >> public: > >> - //! Initialize a rotation in x-y-z order from three angles > >> + Rotation3D(){ > >> + } > >> + //! Initialize a rotation in x-y-z order from three Euler angles > >> /** \param[in] xr Rotation around the X axis > >> \param[in] yr Rotation around the Y axis > >> \param[in] zr Rotation around the Z axis > >> */ > >> Rotation3D(Float xr, Float yr, Float zr) { > >> - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > >> - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > >> - Float m00 = cz*cy; > >> - Float m11 = -sy*sx*sz + cx*cz; > >> - Float m22 = cy*cx; > >> - quat_[0] = sqrt(1+m00+m11+m22)/2.0; > >> - quat_[1] = sqrt(1+m00-m11-m22)/2.0; > >> - quat_[2] = sqrt(1-m00+m11-m22)/2.0; > >> - quat_[3] = sqrt(1-m00-m11+m22)/2.0; > >> - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > >> - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > >> - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > >> + init_angles(xr,yr,zr); > >> } > >> - > >> + //! Initialize a rotation in x-y-z order from three identical > >> Euler angles > >> + /** \param[in] e_angle Rotation around first the X axis, Y axis > >> and Z axis > >> + */ > >> + Rotation3D(Float e_angle){ > >> + init_angles(e_angle, e_angle, e_angle); > >> + } > >> + //! Initialize a rotation in x-y-z order from three Euler angles > >> + /** \param[in] v A vector that holds three Euler angles (x-y-z > >> order) > >> + */ > >> + Rotation3D(const Vector3D &v){ > >> + init_angles(v[0],v[1],v[2]); > >> + } > >> Matrix3D get_matrix() const { > >> const Float a = quat_[0]; > >> const Float b = quat_[1]; > >> @@ -76,7 +78,22 @@ > >> return atan2(matrix21(), matrix11()); > >> } > >> > >> -protected: > >> +private: > >> + void init_angles(Float xr, Float yr, Float zr) { > >> + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > >> + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > >> + Float m00 = cz*cy; > >> + Float m11 = -sy*sx*sz + cx*cz; > >> + Float m22 = cy*cx; > >> + quat_[0] = sqrt(1+m00+m11+m22)/2.0; > >> + quat_[1] = sqrt(1+m00-m11-m22)/2.0; > >> + quat_[2] = sqrt(1-m00+m11-m22)/2.0; > >> + quat_[3] = sqrt(1-m00-m11+m22)/2.0; > >> + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > >> + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > >> + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > >> + } > >> + > >> Float matrix11() const { > >> return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - > >> sqr(quat_[3]); > >> } > >> > >> _______________________________________________ > >> IMP-commits mailing list > >> IMP-commits@salilab.org > >> https://salilab.org/mailman/listinfo/imp-commits > > _______________________________________________ > > IMP-dev mailing list > > IMP-dev@salilab.org > > https://salilab.org/mailman/listinfo/imp-dev > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev >
euler angles are normally defined as rotations around Z/X/Z. it'd be nice to have euler angles as well to be compatible with em packages if you plan to use it for such purposes.
best
frido
On Nov 13, 2008, at 12:59 AM, Dina Schneidman wrote:
> I think these are Euler angles. > http://www.euclideanspace.com/maths/algebra/matrix/orthogonal/rotation/index... > Daniel, I agree that conceptually it is wrong to store them in > Vector3D, but it is very convenient in practice. > > On Wed, Nov 12, 2008 at 10:33 PM, Keren Lasker kerenl@salilab.org > wrote: > Daniel - the angles are not Euler angles but just three angles around > X/Y/Z axis. > Would you like the option to rotate around another axis, ,something > like: > (1,1,0),45 - meaning rotating around the diagonal of the XY plane in > 45 degrees? > On Nov 12, 2008, at 5:43 PM, Daniel Russel wrote: > > > I don't like having two equivalent constructors from thevsame data > or > > using a vector to hold angles. > > > > What I had meant with my suggestion is initialization from an axis > and > > an amount of rotation about that axis as that is a somewhat less > > problematic basis than Euler angles (and one I use :-) > > > > > > > > On Nov 12, 2008, at 2:31 PM, Notification of IMP commits <imp-commits@salilab.org > >> wrote: > > > >> Author: kerenl@SALILAB.ORG > >> Date: 2008-11-12 14:31:59 -0800 (Wed, 12 Nov 2008) > >> New Revision: 854 > >> > >> Modified: > >> trunk/modules/misc/include/Rotation3D.h > >> Log: > >> 1. Change protected to private > >> 2. Add constructors from Vector3D and an angle > >> 3. update documentation > >> > >> Modified: trunk/modules/misc/include/Rotation3D.h > >> =================================================================== > >> --- trunk/modules/misc/include/Rotation3D.h 2008-11-12 21:15:36 > >> UTC (rev 853) > >> +++ trunk/modules/misc/include/Rotation3D.h 2008-11-12 22:31:59 > >> UTC (rev 854) > >> @@ -19,26 +19,28 @@ > >> > >> class IMPMISCEXPORT Rotation3D { > >> public: > >> - //! Initialize a rotation in x-y-z order from three angles > >> + Rotation3D(){ > >> + } > >> + //! Initialize a rotation in x-y-z order from three Euler angles > >> /** \param[in] xr Rotation around the X axis > >> \param[in] yr Rotation around the Y axis > >> \param[in] zr Rotation around the Z axis > >> */ > >> Rotation3D(Float xr, Float yr, Float zr) { > >> - Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > >> - Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > >> - Float m00 = cz*cy; > >> - Float m11 = -sy*sx*sz + cx*cz; > >> - Float m22 = cy*cx; > >> - quat_[0] = sqrt(1+m00+m11+m22)/2.0; > >> - quat_[1] = sqrt(1+m00-m11-m22)/2.0; > >> - quat_[2] = sqrt(1-m00+m11-m22)/2.0; > >> - quat_[3] = sqrt(1-m00-m11+m22)/2.0; > >> - if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > >> - if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > >> - if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > >> + init_angles(xr,yr,zr); > >> } > >> - > >> + //! Initialize a rotation in x-y-z order from three identical > >> Euler angles > >> + /** \param[in] e_angle Rotation around first the X axis, Y axis > >> and Z axis > >> + */ > >> + Rotation3D(Float e_angle){ > >> + init_angles(e_angle, e_angle, e_angle); > >> + } > >> + //! Initialize a rotation in x-y-z order from three Euler angles > >> + /** \param[in] v A vector that holds three Euler angles (x-y-z > >> order) > >> + */ > >> + Rotation3D(const Vector3D &v){ > >> + init_angles(v[0],v[1],v[2]); > >> + } > >> Matrix3D get_matrix() const { > >> const Float a = quat_[0]; > >> const Float b = quat_[1]; > >> @@ -76,7 +78,22 @@ > >> return atan2(matrix21(), matrix11()); > >> } > >> > >> -protected: > >> +private: > >> + void init_angles(Float xr, Float yr, Float zr) { > >> + Float cx = cos(xr); Float cy = cos(yr); Float cz = cos(zr); > >> + Float sx = sin(xr); Float sy = sin(yr); Float sz = sin(zr); > >> + Float m00 = cz*cy; > >> + Float m11 = -sy*sx*sz + cx*cz; > >> + Float m22 = cy*cx; > >> + quat_[0] = sqrt(1+m00+m11+m22)/2.0; > >> + quat_[1] = sqrt(1+m00-m11-m22)/2.0; > >> + quat_[2] = sqrt(1-m00+m11-m22)/2.0; > >> + quat_[3] = sqrt(1-m00-m11+m22)/2.0; > >> + if (cy*sx + sy*cx*sz + sx*cz < 0.0) quat_[1] = -quat_[1]; > >> + if (sz*sx - sy*cx*cz - sy < 0.0) quat_[2] = -quat_[2]; > >> + if (sz*cy + sy*sx*cz + sz*cx < 0.0) quat_[3] = -quat_[3]; > >> + } > >> + > >> Float matrix11() const { > >> return sqr(quat_[0]) + sqr(quat_[1]) - sqr(quat_[2]) - > >> sqr(quat_[3]); > >> } > >> > >> _______________________________________________ > >> IMP-commits mailing list > >> IMP-commits@salilab.org > >> https://salilab.org/mailman/listinfo/imp-commits > > _______________________________________________ > > IMP-dev mailing list > > IMP-dev@salilab.org > > https://salilab.org/mailman/listinfo/imp-dev > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev > > _______________________________________________ > IMP-dev mailing list > IMP-dev@salilab.org > https://salilab.org/mailman/listinfo/imp-dev
--
Friedrich Foerster Planegger Str 65 D-81241 Muenchen Germany
frifoe@gmail.com
Tel: +49 89 81305541
--
Friedrich Foerster Max-Planck Institut fuer Biochemie Am Klopferspitz 18 D-82152 Martinsried
Tel: +49 89 8578 2651 Fax: +49 89 8578 2641
foerster@biochem.mpg.de
www.tomotronic.org
participants (4)
-
Daniel Russel
-
Dina Schneidman
-
Friedrich Foerster
-
Keren Lasker