//Rotate by a random amount. void Coordinates::RotateRand (XYZArray & dest, uint & pStart, uint & pLen, const uint m, const uint b, const double max) { //Rotate (-max, max) radians about a uniformly random vector //Not uniformly random, but symmetrical wrt detailed balance RotationMatrix matrix = RotationMatrix::FromAxisAngle( prngRef.Sym(max), prngRef.PickOnUnitSphere()); XYZ center = comRef.Get(m); uint stop = 0; molRef.GetRange(pStart, stop, pLen, m); //Copy coordinates CopyRange(dest, pStart, 0, pLen); boxDimRef.UnwrapPBC(dest, b, center); //Do rotation for (uint p = 0; p < pLen; p++) //Rotate each point. { dest.Add(p, -center); dest.Set(p, matrix.Apply(dest.Get(p))); dest.Add(p, center); } boxDimRef.WrapPBC(dest, b); }
void CutRange_CurrPos( struct Tracker_Windows *window ){ struct WBlocks *wblock = window->wblock; if( ! window->wblock->isranged) return; CopyRange(wblock); wblock->isranged=true; ADD_UNDO(Range( window, window->wblock, window->wblock->rangex1, window->wblock->rangex2, window->wblock->curr_realline )); Undo_start_ignoring_undo_operations();{ CutRangedRange(wblock); }Undo_stop_ignoring_undo_operations(); UpdateAndClearSomeTrackReallinesAndGfxWTracks( window, wblock, wblock->rangex1, wblock->rangex2 ); window->must_redraw = true; }
//Translate by a random amount void Coordinates::TranslateRand (XYZArray & dest, XYZ & newCOM, uint & pStart, uint & pLen, const uint m, const uint b, const double max) { XYZ shift = prngRef.SymXYZ(max); uint stop=0; //Get range. molRef.GetRange(pStart, stop, pLen, m); //Copy coordinates CopyRange(dest, pStart, 0, pLen); newCOM = comRef.Get(m); //Add translation dest.AddAll(shift); newCOM += shift; //Finish by rewrapping. boxDimRef.WrapPBC(dest, b); newCOM = boxDimRef.WrapPBC(newCOM, b); }