[cctbxbb] Attitude of rotation, Python to C++
Graeme.Winter at Diamond.ac.uk
Graeme.Winter at Diamond.ac.uk
Thu Jan 12 04:03:56 PST 2012
Hi Folks,
Just started moving code from Python to C++ - and seeing a 40x speedup which is nice - however I noticed something odd.
scitbx.matrix.col.rotate(axis, angle)
has the reversed attitude to
scitbx::vec3<double>.rotate(scitbx::vec3<double>, double angle)
viz:
this python code
s = (self._ub * hkl).rotate(self._axis, angle)
q = (s + self._s0).normalize()
# check if diffracted ray parallel to detector face
q_dot_n = q.dot(detector_normal)
if q_dot_n == 0:
continue
r = (q * distance / q_dot_n) - self._detector_origin
x = r.dot(self._detector_fast)
y = r.dot(self._detector_slow)
if x < self._limits[0] or y < self._limits[2]:
continue
if x > self._limits[1] or y > self._limits[3]:
continue
observed_reflection_positions.append((hkl, x, y, angle))
gives the same result as
scitbx::vec3<double> s, q, r;
double x, y, q_dot_n;
/* this is rather weird - the attitude of rotation is back to front in
the c++ code */
s = (ub * hkl).rotate(axis, - angle);
q = (s + s0).normalize();
q_dot_n = q * normal;
if (q_dot_n == 0) return false;
r = (q * distance / q_dot_n) - origin;
x = r * fast;
y = r * slow;
if (x < limits[0]) return false;
if (y < limits[2]) return false;
if (x > limits[1]) return false;
if (y > limits[3]) return false;
prediction[0] = x;
prediction[1] = y;
where I had to use -angle. Code is linked into same routines - used identically. With -angle I get numerically identical results (which is nice)
Anyone got any clues on this one?
Thanks,
Graeme
--
This e-mail and any attachments may contain confidential, copyright and or privileged material, and are for the use of the intended addressee only. If you are not the intended addressee or an authorised recipient of the addressee please notify us of receipt by returning the e-mail and do not use, copy, retain, distribute or disclose the information in or attached to the e-mail.
Any opinions expressed within this e-mail are those of the individual and not necessarily of Diamond Light Source Ltd.
Diamond Light Source Ltd. cannot guarantee that this e-mail or any attachments are free from viruses and we cannot accept liability for any damage which you may sustain as a result of software viruses which may be transmitted in or with the message.
Diamond Light Source Limited (company no. 4375679). Registered in England and Wales with its registered office at Diamond House, Harwell Science and Innovation Campus, Didcot, Oxfordshire, OX11 0DE, United Kingdom
More information about the cctbxbb
mailing list