// Apply transformation --------------------------------------------------- void applyTransformation(const MultidimArray<double> &V2, MultidimArray<double> &Vaux, double *p) { Matrix1D<double> r(3); Matrix2D<double> A, Aaux; double greyScale = p[0]; double greyShift = p[1]; double rot = p[2]; double tilt = p[3]; double psi = p[4]; double scale = p[5]; ZZ(r) = p[6]; YY(r) = p[7]; XX(r) = p[8]; Euler_angles2matrix(rot, tilt, psi, A, true); translation3DMatrix(r,Aaux); A = A * Aaux; scale3DMatrix(vectorR3(scale, scale, scale),Aaux); A = A * Aaux; applyGeometry(LINEAR, Vaux, V2, A, IS_NOT_INV, WRAP); if (greyScale!=1 || greyShift!=0) FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(Vaux) DIRECT_MULTIDIM_ELEM(Vaux,n)=DIRECT_MULTIDIM_ELEM(Vaux,n)*greyScale+greyShift; }
void symmetriseMap(MultidimArray<DOUBLE> &img, FileName &fn_sym, bool do_wrap) { if (img.getDim() != 3) REPORT_ERROR("symmetriseMap ERROR: symmetriseMap can only be run on 3D maps!"); img.setXmippOrigin(); SymList SL; SL.read_sym_file(fn_sym); Matrix2D<DOUBLE> L(4, 4), R(4, 4); // A matrix from the list MultidimArray<DOUBLE> sum, aux; sum = img; aux.resize(img); for (int isym = 0; isym < SL.SymsNo(); isym++) { SL.get_matrices(isym, L, R); applyGeometry(img, aux, R, IS_INV, do_wrap); sum += aux; } // Overwrite the input img = sum / (SL.SymsNo() + 1); }
PhysXSphereCollider::PhysXSphereCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation, float radius) :mRadius(radius) { PxSphereGeometry geometry(radius); PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true); shape->setLocalPose(toPxTransform(position, rotation)); shape->userData = this; mInternal = bs_new<FPhysXCollider>(shape); applyGeometry(); }
PhysXBoxCollider::PhysXBoxCollider(PxPhysics* physx, const Vector3& position, const Quaternion& rotation, const Vector3& extents) :mExtents(extents) { PxBoxGeometry geometry(extents.x, extents.y, extents.z); PxShape* shape = physx->createShape(geometry, *gPhysX().getDefaultMaterial(), true); shape->setLocalPose(toPxTransform(position, rotation)); shape->userData = this; mInternal = bs_new<FPhysXCollider>(shape); applyGeometry(); }
GerberReader::GerberReader(char *firstLayer, char *secondLayer, double offset, Mirror firstLayerMirror, Mirror secondLayerMirror) { mWarnings = 0; mFirstLayerPath = 0; mSecondLayerPath = 0; pMin.x = FLT_MAX; pMin.y = FLT_MAX; pMax.x = -FLT_MAX; pMax.y = -FLT_MAX; GShape *mFirstLayerShape = readFile(firstLayer); GShape *mSecondLayerShape = readFile(secondLayer); pMin.x -= offset; pMin.y -= offset; pMax = pMax - pMin; pMax.x += offset; pMax.y += offset; applyGeometry(mFirstLayerShape, firstLayerMirror); applyGeometry(mSecondLayerShape, secondLayerMirror); mFirstLayerPath = postHandleLayer(mFirstLayerShape); mSecondLayerPath = postHandleLayer(mSecondLayerShape); }
void PhysXSphereCollider::setRadius(float radius) { mRadius = radius; applyGeometry(); }
void PhysXSphereCollider::setScale(const Vector3& scale) { SphereCollider::setScale(scale); applyGeometry(); }
void PhysXMeshCollider::onMeshChanged() { applyGeometry(); }
void PhysXMeshCollider::setScale(const Vector3& scale) { MeshCollider::setScale(scale); applyGeometry(); }
void PhysXBoxCollider::setExtents(const Vector3& extents) { mExtents = extents; applyGeometry(); }
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray*prhs[]) { double angs[3]; const double *p_angs=mxGetPr(prhs[1]); angs[0]=(double)p_angs[0]; angs[1]=(double)p_angs[1]; angs[2]=(double)p_angs[2]; Matrix1D<double> axis; getMatrix1D(prhs[2],axis); Matrix2D<double> A3D, A2D; bool wrap = (bool)mxGetScalar(prhs[5]); mwSize ndims = mxGetNumberOfDimensions(prhs[0]); /*mode: 1 euler, 2 align_with_Z, 3 axis, 4 tform*/ switch ((int)mxGetScalar(prhs[3])) { case 1: Euler_angles2matrix(angs[0], angs[1], angs[2], A3D, true); break; case 2: alignWithZ(axis,A3D); break; case 3: rotation3DMatrix(angs[0], axis, A3D); A2D.resize(3,3); A2D(0,0)=A3D(0,0); A2D(0,1)=A3D(0,1); A2D(0,2)=A3D(0,2); A2D(1,0)=A3D(1,0); A2D(1,1)=A3D(1,1); A2D(1,2)=A3D(1,2); A2D(2,0)=A3D(2,0); A2D(2,1)=A3D(2,1); A2D(2,2)=A3D(2,2); break; case 4: getMatrix2D(prhs[6],A2D); A3D = A2D; break; } if (ndims == 2) { Image<double> img, img_out; getMatrix2D(prhs[0],img()); if (MAT_XSIZE(A2D) != 0) { applyGeometry(BSPLINE3,img_out(), img(), A2D, IS_NOT_INV, wrap); setMatrix2D(img_out(),plhs[0]); } else { setMatrix2D(img(),plhs[0]); } } else { Image<double> vol, vol_out; getMatrix3D(prhs[0],vol()); applyGeometry(BSPLINE3, vol_out(), vol(), A3D, IS_NOT_INV, wrap); setMatrix3D(vol_out(),plhs[0]); } }