BoundingBox::BoundingBox(const Point & pmin,const Point & pmax, const Affine3f & t) { Vector3f offset(pmin - pmax); Vector3f offset_x(offset(0),0,0); Vector3f offset_y(0,offset(1),0); Vector3f offset_z(0,0,offset(2)); Vector3f v[8]; v[0] = pmin; v[1] = pmin + offset_x; v[2] = pmin + offset_y; v[3] = pmin + offset_z; v[4] = pmax - offset_x; v[5] = pmax - offset_y; v[6] = pmax - offset_z; v[7] = pmax; int i; for (i =0;i<8;i++) { v[i] = t * (v[i].colwise().homogeneous()); } float min_x = (v[0]).x(); float min_y = (v[0]).y(); float min_z = (v[0]).z(); float max_x = (v[0]).x(); float max_y = (v[0]).y(); float max_z = (v[0]).z(); for (i =1;i<8;i++) { min_x = min(min_x,(v[i]).x()); min_y = min(min_y,(v[i]).y()); min_z = min(min_z,(v[i]).z()); max_x = max(max_x,(v[i]).x()); max_y = max(max_y,(v[i]).y()); max_z = max(max_z,(v[i]).z()); } min_pos = Point(min_x,min_y,min_z); max_pos = Point(max_x,max_y,max_z); }
void Pic::nonlinear_SC_kick(double xrms, double yrms, double dQxm, double dQym, double tunex, double tuney, Grid1D& ldy, double ldy0, double circum, double ds){ double R = circum/(2.0*PI); double scfact; double offsetx = offset_x(); double offsety = offset_y(); for(long j=0; j<pics.size(); ++j){ scfact = ldy.Field2Pic(pics[j].z)/ldy0; //if( pow(pics[j].x-offsetx, 2)+pow(pics[j].y-offsety, 2) < 6.0*(pow(xrms, 2)+pow(yrms, 2)) ) //{ pics[j].xs-= scfact*2.0*ds*tunex*dQxm/pow(R, 2)* (pics[j].x-offsetx)* (1.0-1.0/18.0*(2.0*xrms+yrms)/(xrms*xrms*(xrms+yrms))*pow(pics[j].x-offsetx, 2)-1.0/(6.0*yrms*(xrms+yrms))*pow(pics[j].y-offsety, 2)); pics[j].ys-= scfact*2.0*ds*tuney*dQym/pow(R, 2)* (pics[j].y-offsety)*(1.0-1.0/18.0*(2.0*yrms+xrms)/(yrms*yrms*(xrms+yrms)) *pow(pics[j].y-offsety, 2)-1.0/(6.0*xrms*(xrms+yrms))*pow(pics[j].x-offsetx, 2)); //} } }